Do it with aggregate(), something like this should do: aggregate(.~cluster, FUN=summary, data=data)
Now if you don't want to run summary(), replace it with the function you'd like.
HTH, Ivan Le 12/13/2010 17:17, effeesse a écrit :
what am I supposed to put into function(x)? The indicator for extracting the subgroups? data is the df. cluster={1,...,14}. This is how I was compiling: "for (i in 1:14) { my.summary<-data$cluster==i c(mean(?),var(?)) summary(var_A~cluster, fun=my.summary,data=data) summary(var_B~cluster, fun=my.summary,data=data) summary(var_C~cluster, fun=my.summary,data=data) summary(var_D~cluster, fun=my.summary,data=data) summary(var_E~cluster, fun=my.summary,data=data) summary(var_F~cluster, fun=my.summary,data=data) summary(var_G~cluster, fun=my.summary,data=data) }" thanks for your patience.
-- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. Säugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calan...@uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.