title: Filtering rows in R unexpectedly removes NAs when using subset or dplyr::filter
body: <p>I have a dataset <code>df</code> and I would like to remove all rows for which variable <code>y</code> does not have the value <code>a</code>. Variable <code>y</code> also contains some <code>NAs</code>:</p>
  
  <pre><code>df &lt;- data.frame(x=1:3, y=c('a', NA, 'c'))
  </code></pre>
  
  <p>I can achieve this using R's indexing syntax like this:</p>
  
  <pre><code>df[df$y!='a',]
  
    x    y
    2 &lt;NA&gt;
    3    c
  </code></pre>
  
  <p>Note this returns both the <code>NA</code> and the value <code>c</code> - which is what I want.</p>
  
  <p>However, when I try the same thing using <code>subset</code> or <code>dplyr::filter</code>, the <code>NA</code> gets stripped out:</p>
  
  <pre><code>subset(df, y!='a')
  
    x    y
    3    c
  
  dplyr::filter(df, y!='a')
    x    y
    3    c
  </code></pre>
  
  <p>Why do <code>subset</code> and <code>dplyr::filter</code> work like this? It seems illogical to me - an <code>NA</code> is not the same as <code>a</code>, so why strip out the <code>NA</code> when I specifiy I want all rows except those where variable <code>y</code> equals <code>a</code>?</p>
  
  <p>And is there some way to change the behaviour of these functions, other than explicitly asking for <code>NAs</code> to get returned, i.e. </p>
  
  <pre><code>subset(df, y!='a' | is.na(y))
  </code></pre>
  
  <p>Thanks</p>