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:
 146688 167
> data2 = na.omit(data$educ)
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?
One easy way to do this is to subset your data. Also, you may want to try use the table function to see if the variable is missing.
table(is.na(data$educ)) test <- subset(data, is.na(educ)) # So you can look at the 2 observations missing this variable data2 <- subset(data, !is.na(educ))