[Data set]
X | Y | Z |
---|---|---|
4.98 | NA | NA |
5.28 | NA | 3.21 |
5.12 | 5.14 | 3.16 |
5.09 | 5.12 | 3.18 |
0 | 0 | 7.12 |
0 | 0 | NA |
d %>% filter(x==0 | y==0 | z==0 | is.na(x) | is.na(y) | is.na(z))
Above R code give me correct results where it filers the dataset and display everything with either 0 or NA in any of the x, y or z as below
X | Y | Z |
---|---|---|
4.98 | NA | NA |
5.28 | NA | 3.21 |
0 | 0 | 7.12 |
0 | 0 | NA |
But when I reverse the condition to negations it is showing everything.
d %>% filter(x!=0 | y!=0 | z!=0 | !is.na(x) | !is.na(y) | !is.na(z))
The expected result is
X | Y | Z |
---|---|---|
5.12 | 5.14 | 3.16 |
5.09 | 5.12 | 3.18 |
But I received the entire data set
Could you please let me know what mistake I made ?