On Fri, Nov 16, 2012 at 2:42 PM, Khan, Sohail <SKhan30@nshs.edu> wrote:

> Thanks. But aggregate will work on rows or columns.  I need to calculate
> mean for subsets of rows in a matrix
> I.E.
>
> Indx     x1     x2      x3       x4     x5      x6      x7      x8      x9
> 1       25      30      15      8       12      9       18      21      89
> 2       52      35      42      74      65      20      28      32      12
> 3       12      35      33      88      12      52      32      32      18
> 4       25      25      16      23      89      21      21      21      42
> ........................................
> ...................................
> I would like to calculate means for x1-x3, x4-x6, x7-x9
> For each row.
>
>
matrix%*%kronecker(diag(6),rep(1/95,95)))

assuming the original is set-up same as above (1-95 , 96 - 190 , ... -570)






> -Sohail
>
>
> -----Original Message-----
> From: John Kane [mailto:jrkrideau@inbox.com]
> Sent: Friday, November 16, 2012 4:35 PM
> To: Khan, Sohail; 'r-help@r-project.org'
> Subject: RE: [R] Calculateing means
>
> ?aggregate will do it.
>
> x <- data.frame( height= c(50, 174, 145, 200, 210, 140, 175),
> age_group=c(1,2,2,1,1,2,1),
>                      ville= c(1,2,3,1,2,3,1))
>
> aggregate(x$height,list(x$age_group, x$ville), mean)
>
> or have a look at the plyr or datatable packages.
>
> John Kane
> Kingston ON Canada
>
>
> > -----Original Message-----
> > From: skhan30@nshs.edu
> > Sent: Fri, 16 Nov 2012 15:58:17 -0500
> > To: r-help@r-project.org
> > Subject: [R] Calculateing means
> >
> >
> > Dear List,
> >
> > I have a data matrix with 570 columns containing 95 (samples) with 6
> > replicates each.
> > How can I calculate the mean of the replicates for 95 samples?
> > Thank you.
> >
> >
> > The information contained in this electronic e-mail transmission and
> > any attachments are intended only for the use of the individual or
> > entity to whom or to which it is addressed, and may contain
> > information that is privileged, confidential and exempt from disclosure
> under applicable law.
> > If the reader of this communication is not the intended recipient, or
> > the employee or agent responsible for delivering this communication to
> > the intended recipient, you are hereby notified that any
> > dissemination, distribution, copying or disclosure of this
> > communication and any attachment is strictly prohibited. If you have
> > received this transmission in error, please notify the sender
> > immediately by telephone and electronic mail, and delete the original
> > communication and any attachment from any computer, server or other
> > electronic recording or storage device or medium. Receipt by anyone
> > other than the intended recipient is not a waiver of any
> attorney-client, physician-patient or other priv!
> >  ilege.
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > 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.
>
> ____________________________________________________________
> Send any screenshot to your friends in seconds...
> Works in all emails, instant messengers, blogs, forums and social networks.
> TRY IM TOOLPACK at http://www.imtoolpack.com/default.aspx?rc=if2 for FREE
>
>
>
>
> The information contained in this electronic e-mail transmission and any
> attachments are intended only for the use of the individual or entity to
> whom or to which it is addressed, and may contain information that is
> privileged, confidential and exempt from disclosure under applicable law.
> If the reader of this communication is not the intended recipient, or the
> employee or agent responsible for delivering this communication to the
> intended recipient, you are hereby notified that any dissemination,
> distribution, copying or disclosure of this communication and any
> attachment is strictly prohibited. If you have received this transmission
> in error, please notify the sender immediately by telephone and electronic
> mail, and delete the original communication and any attachment from any
> computer, server or other electronic recording or storage device or medium.
> Receipt by anyone other than the intended recipient is not a waiver of any
> attorney-client, physician-patient or other priv!
>  ilege.
> ______________________________________________
> 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.
>

	[[alternative HTML version deleted]]


