Remove specific variable from list R : <p>I want to remove a pre-defined variable from a list in R, for example: </p>

<pre><code>vertex &lt;- c("A","B","C","D")    
list_safe&lt;-vertex

z&lt;-sample(list_safe,1)

list_infected[z] &lt;- z

list_safe_new&lt;-list_safe[list_safe =! "z"]
</code></pre>

<p>Somehow, it does not remove z=C (for example) from the list_safe.
Can someone help me?</p>
