[R] summaryBy(): Is it the best option?

Petr Pikal petr.pikal at precheza.cz
Wed Dec 6 10:27:57 CET 2006


Hi

I did not see any answer yet so I try. You can use aggregate, by or 
sapply.

Something like
aggregate(soc6a[, your columns], list(hh=hh), sum, na.rm=T)
by(soc6a[, your columns], hh, sum, na.rm=T)
sapply(split(soc6a[, your columns], hh), sum, na.rm=T)

But you have to check speed gain by yourself.

HTH
Petr



On 5 Dec 2006 at 1:30, Werner Wernersen wrote:

Date sent:      	Tue, 5 Dec 2006 01:30:50 +0100 (CET)
From:           	Werner Wernersen <pensterfuzzer at yahoo.de>
To:             	r-help at stat.math.ethz.ch
Subject:        	[R] summaryBy(): Is it the best option?

> Hi,
> 
> since I have quite large tables and the processing
> takes quite a while I am
> curious if I can improve the performance of this
> aggregation somehow: At the 
> moment I am using summaryBy from the doBy package
> under R 2.4.0, Win2K.
> 
> summaryBy(soc_s6aq5 + soc_s6aq7 + soc_s6aq9 +
> soc_s6aq11 ~ hh + 
> comgroup,soc6a,postfix=c("","","",""),FUN=sum,
> na.rm=T)
> 
> The data.frame has 124100 rows and 13 cols.
> 
> Thanks for any hints!
> 
> Werner
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.

Petr Pikal
petr.pikal at precheza.cz




More information about the R-help mailing list