I want to know how to omit NA values in a data frame, but only in some columns I am interested in.
NA
For example,
DF <- data.frame(x =
Use is.na
is.na
DF <- data.frame(x = c(1, 2, 3), y = c(0, 10, NA), z=c(NA, 33, 22)) DF[!is.na(DF$y),]
Use 'subset'
DF <- data.frame(x = c(1, 2, 3), y = c(0, 10, NA), z=c(NA, 33, 22)) subset(DF, !is.na(y))