1

I'm using R to filter data in the case where two columns ARE NOT missing. When I enter the code in two different ways, the total count of rows are not the same. Are the following codes saying the same thing?

df <- subset(df, !is.na(columnA) & !is.na(columnB))

df <- df[!(is.na(df$columnA) & is.na(df$columnB)), ]

It appears that the first code is deleting rows where column A OR column B is empty. Whereas, code 2 actually deletes the row IF column A AND column B is empty.

neilfws
  • 32,751
  • 5
  • 50
  • 63
Kristine
  • 171
  • 5

0 Answers0