我有一个1488的数据帧。和400var。我正在尝试记录表中的所有值,然后通过命令rm.outlier使用包异常值,我正在尝试删除异常值。唯一的问题是我得到了这个错误:
Error in data.frame(V1 = c(-0.886056647693163, -0.677780705266081, -1.15490195998574, : arguments imply differing number of rows: 1487, 1480, 1481, 1475, 1479, 1478, 1483, 1485, 1484, 1477, 1482, 1469这是我的代码:
datalog <- matrix(0,nrow(data),ncol(data))
datalog[,] <- apply(data,2,log10)
datalog[datalog==-Inf] <- 0
datalog <- as.data.frame(datalog, stringsAsFactors=F)
testNoOutliers <- rm.outlier(datalog, fill = FALSE,
median = FALSE, opposite = FALSE)我的数据:https://skydrive.live.com/redir?resid=CEC7696F3B5BFBC6!341&authkey=!APiwy6qasD3-yGo
谢谢你的帮助
发布于 2012-12-03 23:12:27
出现此错误是因为从每列中删除了不同数量的异常值,因此不能将列放在一个数据帧中。
out.rem<-function(x) {
x[which(x==outlier(x))]=NA
x
}
apply(datalog,2,out.rem)要删除包含离群值的整个行,可以向@agstudy解决方案添加额外的行
ll <- apply(datalog,2,function(x) which(x == outlier(x)))
new.datalog <- datalog[-unique(unlist(ll)),]发布于 2012-12-04 01:08:49
你得到这个错误是因为你没有相同数量的异常值条形变量。
要纠正此错误,您有两个选择:
(X)
https://stackoverflow.com/questions/13685914
复制相似问题