[datatable-help] data.table and reshape
Zachary Mayer
zach.mayer at gmail.com
Mon Aug 1 20:02:51 CEST 2011
Hello,
I was wondering what is the best way to reshape a data table. Is it
appropriate to use the 'reshape' function in base r, or is there a better
way?
Here is an example:
library(data.table)set.seed(1234)
DT <- data.table(x=rep(c("a","b","c"),each=4), y=c("AA","BB"),
v=sample(1:100,12)out <- DT[,sum(v),by='x,y']
names(out)[3] <- 'SUM'out <- reshape(out,direction='wide',idvar='x',
timevar='y')
Thank you.
-Zach
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20110801/ed2890e9/attachment-0001.htm>
More information about the datatable-help
mailing list