R Error in :missing values are not allowed in subscripted assignments of data frames
Posted qq_21478261
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了R Error in :missing values are not allowed in subscripted assignments of data frames相关的知识,希望对你有一定的参考价值。
模拟报错发生:
#生成一个data.frame
set.seed(0)
data <- data.frame(x=c(NA, rnorm(99)), y=c(1:5))
head(data)
生成一个6x2的data.frame,包含一个NA值,
,
#将data.frame中小于0的值替换为0
data[data$x<0,]$x <- 0
报错发生了:
Error in `[<-.data.frame`(`*tmp*`, data$x < 0, , value = list(x = c(0, :
missing values are not allowed in subscripted assignments of data frames
报错很明显,da
以上是关于R Error in :missing values are not allowed in subscripted assignments of data frames的主要内容,如果未能解决你的问题,请参考以下文章
R语言进行缺失值填充(Filling in missing values):使用R原生方法data.tabledplyr等方案
Error in if (x[i] == NA) { : missing value where TRUE/FALSE needed
Error in if (x[i] == NA) { : missing value where TRUE/FALSE needed
Error in na.fail.default(list(Purchase = c(“CH“, “CH“, “CH“, “MM“, “CH“, : missing values in obj