Re: [R] means and variances of several groups in the matrix

From: Jim Lemon <jim_at_bitwrit.com.au>
Date: Mon, 21 Apr 2008 20:31:41 +1000

kathie wrote:
> Dear R users,
>
> I have 32 observations in data x. After sorting this, I want to compute
> means and variances of 3 groups divided by "nr".
>
> Actually, the number of groups is flexible. Any suggestion will be greatly
> appreciated.
>
Hi Kathryn,
One way (there are many others) is to use the brkdn function in the prettyR package. You have to create a grouping variable, but it's pretty easy...

group1<-rep(1:3,each=nr[1,])
group2<-rep(1:3,each=nr[2,])
y.df<-data.frame(y=y,group1=group1,group2=group2) brkdn(y~group1,y.df,num.desc=c("mean","var")) brkdn(y~group2,y.df,num.desc=c("mean","var"))

Jim



R-help_at_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. Received on Mon 21 Apr 2008 - 10:31:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 21 Apr 2008 - 11:30:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive