I have a dataset `df` and I would like to remove all rows for which variable `y` does not have the value `a`. Variable `y` also contains some `NAs`:

```
df <- data.frame(x=1:3, y=c('a', NA, 'c'))

```

I can achieve this using R's indexing syntax like this:

```
df[df$y!='a',]

  x    y
  2 <NA>
  3    c

```

Note this returns both the `NA` and the value `c` - which is what I want.

However, when I try the same thing using `subset` or `dplyr::filter`, the `NA` gets stripped out:

```
subset(df, y!='a')

  x    y
  3    c

dplyr::filter(df, y!='a')
  x    y
  3    c

```

Why do `subset` and `dplyr::filter` work like this? It seems illogical to me - an `NA` is not the same as `a`, so why strip out the `NA` when I specifiy I want all rows except those where variable `y` equals `a`?

And is there some way to change the behaviour of these functions, other than explicitly asking for `NAs` to get returned, i.e. 

```
subset(df, y!='a' | is.na(y))

```

Thanks