[R] more on apply on data frame
Laura Holt
lauraholt_983 at hotmail.com
Sat Aug 21 06:40:16 CEST 2004
Hi R People:
Several of you pointed out that using "tapply" on a data frame will work on
the iris data frame.
I'm still having a problem.
The iris data frame has 150 rows, 5 variables. The first 4 are numeric,
while the last is a factor, which has the Species names.
I can use tapply for 1 variable at a time:
>tapply(iris[,1],iris[,5],mean)
setosa versicolor virginica
5.006 5.936 6.588
>
but if I try to use this for all of the first 4, I get an error:
>tapply(iris[,1:4],iris[,5],mean)
Error in tapply(iris[, 1:4], iris[, 5], mean) :
arguments must have same length
>
Any ideas of what I'm doing wrong, please?
Thanks,
Laura Holt
mailto: lauraholt_983 at hotmail.com
R Version 1.9.1
Windows
More information about the R-help
mailing list