Is there was a way to sample only non-null values in R? Currently, I have this code.
s <- sample(200000, replace=TRUE);
m <- mydata$myvar[s]
However, some elements of m
are null. Is there such a simple command as the following?
s <- sample(200000, replace=TRUE, na.rm=TRUE);
s <- sample(mydata$myvar, replace=TRUE, na.rm=TRUE);
The documentation does not state such option exists.
You can just remove the NULL
elements afterwards:
m <- m[!is.null(m)]