[Rd] by "infelicity"
Tobias Verbeke
tobias.verbeke at telenet.be
Thu Apr 3 13:42:36 CEST 2008
Dear list,
Please find below an example of odd
behaviour of the by function.
It occurs both under GNU/Linux R 2.6.2
and Windows R 2.7.0alpha. Respective
sessionInfo()'s are given below.
I hope I do not overlook anything.
testFactor <- factor(sample(LETTERS[1:6], size = 42, replace = TRUE))
testMatrix <- matrix(rnorm(42 * 6), nrow = 42)
testDf <- as.data.frame(testMatrix)
by(data = testDf, INDICES = testFactor, FUN = mean) # OK
by(data = testDf, INDICES = testFactor, FUN = median) # error
# Error in median.default(data[x, ], ...) : need numeric data
Kind regards,
Tobias
### GNU/Linux ###
> sessionInfo()
R version 2.6.2 (2008-02-08)
i486-pc-linux-gnu
locale:
LC_CTYPE=en_US.UTF-8;LC_NUMERIC=C;LC_TIME=en_US.UTF-8;LC_COLLATE=en_US.UTF-8;LC_MONETARY=en_US.UTF-8;LC_MESSAGES=en_US.UTF-8;LC_PAPER=en_US.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US.UTF-8;LC_IDENTIFICATION=C
attached base packages:
[1] tools stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] Biobase_1.16.3
### Windows ###
> sessionInfo()
R version 2.7.0 alpha (2008-03-29 r44988)
i386-pc-mingw32
locale:
LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United Kingdom.1252;LC_MONETARY=English_United Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
>
More information about the R-devel
mailing list