title: How does the logical negation operator ! work?
body: <p>I am not trying to solve any particular problem, but trying to learn R and understand its logical negation operator &quot;!&quot; documented on page <a href="http://stat.ethz.ch/R-manual/R-devel/library/base/html/Logic.html" rel="nofollow noreferrer">http://stat.ethz.ch/R-manual/R-devel/library/base/html/Logic.html</a></p>
  <p>It works for me when used in combination with =, in expressions such as:</p>
  <pre><code>1 != 2
  TRUE
  </code></pre>
  <p>But I can't quite comprehend standalone application of this operator. For instance, can I use it to select elements of the list which do not have specific name. Here's my attempt to do that, but it did not work:</p>
  <pre><code>vector1 &lt;- 1:5 # just making vector of 5 numbers
  vector2 &lt;- 5:1 # same vector backwards
  list &lt;- list(Forward=vector1, Backwards=vector2) # producing list with two elements
  x = &quot;Forward&quot;
  list[!x]
  </code></pre>
  <p>My output is:</p>
  <pre><code>Error in !x : invalid argument type
  </code></pre>
  <p>Will appreciate any hints on where my logic goes wrong in this case, and what are other good uses of this operator except for != case.</p>