r语言提示invalid argument to unary operator怎么解决

Python017

r语言提示invalid argument to unary operator怎么解决,第1张

da <- function(x){

c=c()

for (i in seq(ncol(x))){

#if (length(which(complete.cases(x[[i]])))>1) #如何某列有空值

if(sum(complete.cases(x[i]==FALSE)>=1)

{c=c(i,c)}

}

x=x[-c]

}

你先试试这样

lm.test=lm(y~x1+x2,test)

根据你的报错:non-numeric argument to function

就是说你的数据里面有非数字型的,可能是NA,可能是字符“n/a” 仔细排查一下吧

首先,如果想要别人复现出跟你一样的结果,要先设置随机种子

Set the seed of R‘s random number generator, which is useful for creating simulations or random objects that can be reproduced.

If you want to generate a decimal number where any value (including fractional values) between the stated minimum and maximum is equally likely, use the runif function.

The first argument is a vector of valid numbers to generate (here, the numbers 1 to 10), and the second argument indicates one number should be returned.

If we want to generate more than one random number, we have to add an additional argument to indicate that repeats are allowed: