我有与此相关的新问题,我的主题 删除 r 中的异常值并考虑名义 var。在新情况下,变量 x 和 x1 具有不同的长度
x <- c(-10, 1:6, 50)
x1<- c(-20, 1:5, 60)
z<- c(1,2,3,4,5,6,7,8)
bx <- boxplot(x)
bx$out
bx1 <- boxplot(x1)
bx1$out
x<- x[!(x %in% bx$out)]
x1 <- x1[!(x1 %in% bx1$out)]
x_to_remove<-which(x %in% bx$out)
x <- x[!(x %in% bx$out)]
x1_to_remove<-which(x1 %in% bx1$out)
x1 <- x1[!(x1 %in% bx1$out)]
z<-z[-unique(c(x_to_remove,x1_to_remove))]
z
data.frame(cbind(x,x1,z))
Run Code Online (Sandbox Code Playgroud)
然后我收到警告
Warning message:
In cbind(x, x1, z) :
number of rows of result is not a multiple of vector length (arg 2)
Run Code Online (Sandbox Code Playgroud)
所以在新的数据框中 …