>----- Oorspronkelijk bericht ----- >Van: Peter Dalgaard [mailto:[EMAIL PROTECTED] >Verzonden: donderdag, april 3, 2008 02:16 PM >Aan: 'Tobias Verbeke' >CC: r-devel@r-project.org >Onderwerp: Re: [Rd] by "infelicity" > >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.
Apologies. Thanks for the clarification. Kind regards, Tobias ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel