【发布时间】:2020-01-31 01:06:02
【问题描述】:
我有一个数据集 df,我从 Excel 读取到 R。出于某种原因,在读取文件时,R 将所有空字段设置为 NA。我该如何扭转这个?我希望将列中的 NA 值转换回空单元格。
Subject Value
hello NA
hello NA
hello NA
我想要:
Subject Value
hello
hello
hello
这是输出:
structure(list(Subject = structure(c(1L, 1L, 1L), .Label = "hello", class = "factor"),
Value = c(NA, NA, NA)), class = "data.frame", row.names = c(NA,
-3L))
这是我尝试过的:
df[is.na(df$Value)] <- " "
.
我不知道这个结构是否正确 任何帮助表示赞赏。
【问题讨论】: