[R] ddply from plyr package - any alternatives?
Paul Hiemstra
paul.hiemstra at knmi.nl
Thu Aug 25 09:27:39 CEST 2011
Hi Adam,
A recent thread on R-help deals exactly with your problem. In one of the
responses I compare ddply to a number of alternative solutions (using
ave and data.table) [1]. The test in the e-mail shows that for large
amounts of unique categories, ddply is quite slow. Hadley (Wickham,
author of ddply) remarked in reply to a question on the plyr mailing
list that this was due to how ddply was setup [2]. So in your case I
would definitely take a look at data.table, which is probably much
faster. If that does not work, take a look at ave which is also quite a
bit faster for your problem.
cheers,
Paul
[1] http://www.mail-archive.com/r-help@r-project.org/msg142797.html
[2]
http://groups.google.com/group/manipulatr/browse_thread/thread/5e8dfed85048df99
On 08/24/2011 04:25 PM, AdamMarczak wrote:
> Hello everyone,
> I was asked to repost this again, sorry for any inconvenience.
>
> I'm looking replacement for ddply function from plyr package.
> Function allows to apply function by category stored in any column/columns.
>
> Regular loops or lapplys slow down greatly because my unique combination
> count exceeds 9000. Is there any available solution which allow me to apply
> function by category?
>
> currently my code looks like snippet below
>
> ddply(myData, c("country_name", "product_name"), myFunction)
>
> Please note that I'm looking for decently performing resolution.
>
> Thanks in advance!
>
> With regards,
> Adam.
>
> --
> View this message in context: http://r.789695.n4.nabble.com/ddply-from-plyr-package-any-alternatives-tp3765936p3765936.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
--
Paul Hiemstra, Ph.D.
Global Climate Division
Royal Netherlands Meteorological Institute (KNMI)
Wilhelminalaan 10 | 3732 GK | De Bilt | Kamer B 3.39
P.O. Box 201 | 3730 AE | De Bilt
tel: +31 30 2206 494
http://intamap.geo.uu.nl/~paul
http://nl.linkedin.com/pub/paul-hiemstra/20/30b/770
More information about the R-help
mailing list