[R] how do I get means by factor?

BXC (Bendix Carstensen) bxc at steno.dk
Wed Feb 23 23:16:17 CET 2005


tapply( x, f, mean )

maybe with

tapply( x, f, mean, na.rm=T )

----------------------
Bendix Carstensen
Senior Statistician
Steno Diabetes Center
Niels Steensens Vej 2
DK-2820 Gentofte
Denmark
tel: +45 44 43 87 38
mob: +45 30 75 87 38
fax: +45 44 43 07 06
bxc at steno.dk
www.biostat.ku.dk/~bxc
----------------------



> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Chris
> Sent: Wednesday, February 23, 2005 10:38 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] how do I get means by factor?
> 
> 
> I want the mean of a response variable for each level of a 
> factor in a data.frame.  How is this done?
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read 
> the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list