[R] apply on a data frame

Laura Holt lauraholt_983 at hotmail.com
Fri Aug 20 18:27:26 CEST 2004


Hi R People:

There are 2 data sets of the iris data: one is iris3, which is a 3-d array, 
and the other is iris, which
is a data frame with 150 rows and 6 variables.

Getting means is straightforward from the 3-day iris3 set:
>apply(iris3,c(2,3),mean)
         Setosa Versicolor Virginica
Sepal L.  5.006      5.936     6.588
Sepal W.  3.428      2.770     2.974
Petal L.  1.462      4.260     5.552
Petal W.  0.246      1.326     2.026
>

Is there is similar way to obtain those values from the iris data frame, 
please?

thanks in advance
R Version 1.9.1 Windows.

Sincerely,
Laura Holt
mailto: lauraholt_983 at hotmail.com




More information about the R-help mailing list