[R] grouped colSums without for loops?

Hans Ekbrand hans at sociologi.cjb.net
Tue Mar 18 12:22:08 CET 2008


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20080318/9444e116/attachment.bin 


More information about the R-help mailing list