Tobias Verbeke wrote: > 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 > The infelicity (if any) is not in by(). Try
mean(airquality) median(airquality) The FUN in by() is applied to the subsetted data frame, and there is no median.data.frame method. -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel