na.strings applied to a dataframe

前端 未结 4 544
無奈伤痛
無奈伤痛 2021-01-18 07:41

I currently have a dataframe in which there are several rows I would like converted to \"NA\". When I first imported this dataframe from a .csv, I could use na.strings=c(\"A

4条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-18 08:07

    data[ data == "D" ] = NA
    

    Note that if you were trying to replace NA with "D", the reverse (df[ df == NA ] = "D") will not work; you would need to use df[is.na(df)] <- "D"

提交回复
热议问题