Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 更换NA有困难吗_R - Fatal编程技术网

R 更换NA有困难吗

R 更换NA有困难吗,r,R,我是R的新手,我使用的是kaggle的数据集 我想用“UKNOWN”来替换一列中的所有NA,但我明白了 Warning message: In `[<-.factor`(`*tmp*`, is.na(operations[,"theater.of.operations"]), : invalid factor level, NA generated 警告消息: 在“[中,要将NA(不是字符串类型)转换为字符串,如“UNKNOWN”,您需要将数据帧列转换为字符串,如下所示 operati

我是R的新手,我使用的是kaggle的数据集

我想用“UKNOWN”来替换一列中的所有NA,但我明白了

Warning message:
In `[<-.factor`(`*tmp*`, is.na(operations[,"theater.of.operations"]),  :
invalid factor level, NA generated
警告消息:

在“[中,要将
NA
(不是字符串类型)转换为字符串,如
“UNKNOWN”
,您需要将数据帧列转换为字符串,如下所示

operations$theater.of.operations <- as.character(operations$theater.of.operations)

operations$theater.of.operations使用as.character()转换为characterTry为了在Sotos提到可能重复的“很高兴它为您工作”时,首先将您的df列转换为一个字符,我将为您的问题添加一个正式答案:)是的,这些是非常重复的,但不准确。我认为必须理解,用户可能没有足够的现有知识来理解这些问题的关系对他们的问题的回答应该是可以接受的。
operations$theater.of.operations <- as.character(operations$theater.of.operations)