处理缺失值的一般步骤
《数据分析基础——R语言(处理缺失值)》https://blog.csdn.net/qq_35164554/article/details/97805065?utm_source=app&app_version=4.21.1
一、用0替代数据框中的NA值
《如何在R数据帧中用零替换NA值?》
https://blog.csdn.net/CHCH998/article/details/105528282?utm_source=app&app_version=4.21.1
《R语言数据框中,用0替代NA缺失值 - yangk - 博客园》
二、删除NA值
is.na()
> x <- c(1, 2, NA, 4, NA, 5) > bad <- is.na(x)
> print(bad)
[1] FALSE FALSE TRUE FALSE TRUE FALSE
> x[!bad]
[1] 1 2 4 5
complete.cases()
> x <- c(1, 2, NA, 4, NA, 5) > y <- c("a", "b", NA, "d", NA, "f") > good <- complete.cases(x, y)
> g