[R] unable to remove NAs from a data frame

Ana Marija @okov|c@@n@m@r|j@ @end|ng |rom gm@||@com
Thu Sep 16 16:12:05 CEST 2021


Hi All,

I have lines in file that look like this:

> df[14509227,]
    SNP   A1   A2 freq  b se  p  N
1: <NA> <NA> <NA>   NA NA NA NA NA

data looks like this:
> head(df)
           SNP A1 A2      freq       b     se      p      N
1:  rs74337086  G  A 0.0024460  0.1627 0.1231 0.1865 218792
2:  rs76388980  G  A 0.0034150  0.1451 0.1047 0.1660 218792
...
> sapply(df,class)
        SNP          A1          A2        freq           b          se
"character" "character" "character"   "numeric"   "numeric"   "numeric"
          p           N
  "numeric"   "integer"

> dim(df)
[1] 14509225        8

Tried:
> df=na.omit(df)
> dim(df)
[1] 14509225        8

and:
> library(tidyr)
> d=df %>% drop_na()
> dim(d)
[1] 14509225        8


Please advise,

Thanks
Ana



More information about the R-help mailing list