2

Here's what had happened:

> NA.of.df = which(rowSums(is.na(df)) == ncol(df))
> NA.of.df 
named integer(0)
> fix(df) # i want to see what's in here -- nothing wrong
> NA.of.df # so i run it again  
1 3 5 7 9 # it works!

why would this happens??

A producible example (but doesn't seems like any data structure with dput()) is like the following:

> dput(NA.of.df)
structure(integer(0), .Names = character(0))

and NA.of.df is just the code for finding rows with all NAs (obtained from here: Remove rows in R matrix where all data is NA). (i.e. NA.of.df = which(rowSums(is.na(df)) == ncol(df)))

Math Avengers
  • 762
  • 4
  • 15

1 Answers1

2

It could be an issue with quotes around the NA resulting in is.na to not pick up those elements

is.na(c(NA, "NA"))
#[1]  TRUE FALSE

After doing the fix, it may have dropped the quotes and evaluate it correctly

akrun
  • 874,273
  • 37
  • 540
  • 662