Skip to content
Back to formatted view

Raw Message

Message-ID: <39B6DDB9048D0F4DAD42CB26AAFF0AFA056BA387@usctmx1106.merck.com>
Date: 2008-03-18T13:06:05Z
From: Liaw, Andy
Subject: grouped colSums without for loops?
In-Reply-To: <20080318112204.GD9049@amin>

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 at 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}}