[R] How to calculate the stratified means in a data frame?

Frank Duan fhduan at gmail.com
Thu Nov 18 22:07:43 CET 2004


Got it. Many thanks.


On Thu, 18 Nov 2004 13:10:53 -0800, Jeff Laake <jeff.laake at noaa.gov> wrote:
> look at "by"
> 
> 
> 
> Frank Duan wrote:
> 
> > Dear R people,
> >
> > I have a simple question to ask. Suppose I have a data.frame with two
> > variables: one factor (x) and one numeric (y), I want to calculate the
> > mean of y for each value of x. Although it's easy to do it within a
> > for a loop, I believe there may be a concise way by using some kinds
> > of "apply" functions. Could anyone tell me how to do that? Thank you.
> >
> > Frank
> >
> > ______________________________________________
> > 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