[Rd] bug in by.data.frame, R-2.6.1 (PR#10506)
ligges at statistik.uni-dortmund.de
ligges at statistik.uni-dortmund.de
Mon Dec 10 16:05:09 CET 2007
by() fails for 1-column matrices and dataframes:
X <- data.frame(a=1:10)
g <- gl(2,5)
by(X, g, colMeans)
Suggested fix:
--- by-old.R 2007-12-10 15:26:22.501086600 +0100
+++ by.R 2007-12-10 15:25:58.390477200 +0100
@@ -26,7 +26,7 @@
IND[[1]] <- INDICES
names(IND) <- deparse(substitute(INDICES))[1]
} else IND <- INDICES
- FUNx <- function(x) FUN(data[x,], ...)
+ FUNx <- function(x) FUN(data[x, , drop=FALSE], ...)
nd <- nrow(data)
ans <- eval(substitute(tapply(1:nd, IND, FUNx)), data)
attr(ans, "call") <- match.call()
_
platform i386-pc-mingw32
arch i386
os mingw32
system i386, mingw32
status
major 2
minor 6.1
year 2007
month 11
day 26
svn rev 43537
language R
version.string R version 2.6.1 (2007-11-26)
Uwe Ligges
More information about the R-devel
mailing list