[R] ddply from plyr package - any alternatives?

Hadley Wickham hadley at rice.edu
Thu Aug 25 14:03:11 CEST 2011


> z <- ddply(past, c("GEO_CNTRY_NAME","PROD_SEG_NAME"),
>  function(x) summary(lm(VAL~fy,x))$r.squared)
>
> But when ave is not exactly doing what I need. Above code runs under a
> minute for my data set where as ave runs over 8 mins.

It's hard to know without a reproducible example, but I doubt that
ddply is the bottleneck in that code. I'd suspect that it's the linear
model fitting that takes the majority of the time

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-help mailing list