I am trying to eliminate the rows in my dataset that have as values of the variable income either 0 or NA. By running the two lines of code below, I found out that there are 1039 observations with the characteristics that I am looking for. In particular, even though I am only asking for income equal to 0, r automatically takes into also the NA values.
length(allregions$income[allregions$emp == 1 & allregions$income == 0])
allregions$income[allregions$emp == 1 & allregions$income == 0]
However, when I try to eliminate those rows, r only deletes the rows with income equal to 0 and keeps those with NA. Even if I add NA in the condition, those values still remain in my dataset.
allregions <- allregions[!(allregions$income == 0 & allregions$emp == 1),]
How can I drop the rows with NAs in a particular column? Also, how is it possible that even though I apply the same condition, in one case R takes into account NAs too and in another it doesn't?
Thank you in advance for your help!