Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数据框。行和列都被标记。我想将列的 - 比如说名为abc - 的值替换为NA.
NA
这是你想做的吗?
df <- data.frame(a=c(1,2,3), b=c(6,7,8)) df$a <- NA df a b 1 NA 6 2 NA 7 3 NA 8
仔细检查它是否真的是 NA:
is.na(df$a) [1] TRUE TRUE TRUE
将列设置为 NA 的另一种方法:
is.na(df$a) <- df$a df a b 1 NA 6 2 NA 7 3 NA 8