Re: [R] grouped colSums without for loops?

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Tue, 18 Mar 2008 09:06:05 -0400

See ?rowsum. The other two suggestions are both shown in the Example section as well (with comment).

Andy

From: Hans Ekbrand
>
> * PGP Signed by an unknown key: 03/18/2008 at 06:22:03 AM
> On Tue, Mar 18, 2008 at 05:57:59AM -0500, jim holtman wrote:
> > Is this what you want?
> >
> > > lapply(split(d, d$foo), function(x) colSums(x[,-1]))
>
> Yes! Thank you! the *apply functions seem very powerful, thanks again
> for giving me a hint on how to use them.
>
> --
> Hans Ekbrand (http://sociologi.cjb.net) <hans@sociologi.cjb.net>
> Q. What is that strange attachment in this mail?
> A. My digital signature, see www.gnupg.org for info on how you could
> use it to ensure that this mail is from me and has not been
> altered on the way to you.
> * Unknown Key
> * 0x7050614E (L)
>
>



Notice: This e-mail message, together with any attachme...{{dropped:15}}

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 Tue 18 Mar 2008 - 13:12:17 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 Tue 18 Mar 2008 - 13:30:22 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