我有一个脚本,有一堆质量控制校验和,它捕捉到一个数据集,因为质量控制,不需要删除任何样本(行)。然而,这个脚本给了我一个零行数据框的意外结果。带有示例数据,为什么这项工作:从数据帧中删除零线产生零线的数据帧
data(iris)
##get rid of those pesky factors
iris$Species <- NULL
med <- which(iris[, 1] < 4.9)
medtemp <- iris[-med, ]
dim(medtemp)
[1] 134 4
但这返回零行的数据帧:
small <- which(iris[, 1] < 4.0)
smalltemp <- iris[-small, ]
dim(smalltemp)
[1] 0 4
至于做这个的:
x <- 0
zerotemp <- iris[-x, ]
dim(zerotemp)
[1] 0 4
看来,smalltemp
数据帧应与iris
的尺寸相同,因为根本没有要移除的行。为什么是这样?
总是很好看将R地狱引用讨论这个答案意味着它可能会再次进行审查的好时机。 – Stedy 2011-05-27 21:20:35