summary still shows NAs after using both na.omit and complete.cases

后端 未结 2 2107
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-27 05:04

I am a grad student using R and have been reading the other Stack Overflow answers regarding removing rows that contain NA from dataframes. I have tried both na.omit and comple

2条回答
  •  臣服心动
    2021-01-27 05:35

    1. The error is that you actually didn't assign the output from na.omit !

      Perios <- na.omit(Perios)

    2. If you know which column the NAs occur in, then you can just do

      Perios[!is.na(Perios$Periostitis),]

    or more generally:

    Perios[!is.na(Perios$colA) & !is.na(Perios$colD) & ... ,]
    

    Then as a general safety tip for R, throw in an na.fail to assert it worked:

    na.fail(Perios)  # trust, but verify! Die Paranoia ist gesund.
    

提交回复
热议问题