How to just extract the cells where the values are lower than 0 including NAs ?
I would like to have a vector as an output.
How to just extract the cells where the values are lower than 0 including NAs ?
I would like to have a vector as an output.
Have a look at the way to subset items from a vector using ?'['
> set.seed(0)
> x <- c(rnorm(10),NA)
> x
[1] 1.262954285 -0.326233361 1.329799263 1.272429321 0.414641434
[6] -1.539950042 -0.928567035 -0.294720447 -0.005767173 2.404653389
[11] NA
> x[x<0 |is.na(x)]
[1] -0.326233361 -1.539950042 -0.928567035 -0.294720447 -0.005767173
[6] NA