na.strings applied to a dataframe

前端 未结 4 567
無奈伤痛
無奈伤痛 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:03

    Since we don't have your data I will use mtcars. Suppose we want to set values anywhere in mtcars that are equal to 4 or 19.2 to NA

    ind <- which(mtcars == 4, arr.ind = TRUE)
    mtcars[ind] <- NA
    

    In your setting you would replace this number by "D" or "E"

提交回复
热议问题