I am trying to drop all of my NAs for an education variable in my data using the na.omit() function in R. However, the function drops all of my observations in the data, although there are only two NAs for the education variable. Below is the R output:
> dim(data)
[1] 146688 167
> sum(is.na(data$educ))
[1] 2
> data2 = na.omit(data$educ)
> dim(data2)
NULL
The sum(is.na()) function counts only two NAs, so na.omit() should only drop two rows, correct? Why is the function dropping all of my observations?
data2
. It's an atomic vector. Atomic vectors have nodim
attribute. To usena.omit
on the entire data set, don't extract the column. A reproducible example would be just terrific.