[R] ddply from plyr package - any alternatives?

AdamMarczak adam.marczak at gmail.com
Fri Aug 26 11:14:46 CEST 2011


Thank you all for suggestions, they were great and informative. 
I will surely use data.tables in future when our server will be upgraded for
now this is solution that I used. This solution performs exactly same task
and produces exact same results at ddply.


  s <- split(past, paste(past$"CNTRY_NAME",past$"SEG_NAME"))	
  R2 <- lapply(s, function(x) return(list(x$"CNTRY_NAME"[1], x$"SEG_NAME[1],
summary(lm(VAL~fy,x))$r.squared)));
  R2 <- data.frame(do.call(rbind, R2))
  R2[,1] <- unlist(R2[,1]); R2[,2] <- unlist(R2[,2]); R2[,3] <-
unlist(R2[,3]);
  colnames(R2)[1:3] <- c("CNTRY_NAME","SEG_NAME","V1")
  R2<-R2[order(R2$CNTRY_NAME,R2$SEG_NAME),]


Above lines produce exactly same result as ddply in the exactly same fashion
allow quick replacement of ddply without any further rebuild of the code
(sorting is just precaution).

Best regards,
Adam.

--
View this message in context: http://r.789695.n4.nabble.com/ddply-from-plyr-package-any-alternatives-tp3765936p3770352.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list