Hello. The data.table package is very helpful in terms of speed. But I am
having trouble actually using the output from linear regression. Is there
any way to get the data.table output to be as pretty/useful as that from
the plyr package? Below is an example.
library('data.table');
library('plyr');
REG <-
data.table(ID=c(rep('Frank',5),rep('Tony',5),rep('Ed',5)),
y=rnorm(15), x=rnorm(15), z=rnorm(15));
REG;
#The ddply function from the plyr package produces very neat and useful
output;
ddply(REG, .(ID), function(x) coef(lm(y ~ x + z, data=x)));
#The data.table output is fast, but not very neat (in terms of the order of
the coefficient estimates). Is there any way to get the data.table output
to look more like the plyr/ddply output (without making a list for each
coef and running the regression two times)?
REG[, coef(lm(y ~ x + z)), by=ID];
Thank you! Geoff
[[alternative HTML version deleted]]
Hi Geoff,
Please see this part of the r-help posting guide :
" For questions about functions in standard packages distributed with
R
(see the FAQ Add-on packages in R), ask questions on R-help. If the
question relates to a contributed package , e.g., one downloaded from CRAN,
try contacting the package maintainer first. You can also use
find("functionname") and packageDescription("packagename")
to find this
information. ONLY send such questions to R-help or R-devel if you get no
reply or need further assistance. This applies to both requests for help and
to bug reports. "
Where I've capitalised ONLY since it is bold in the original HTML. I only
saw your post thanks to Google Alerts.
maintainer("data.table") returns the email address of the
datatable-help
list, with the posting guide in mind. However, for questions like this, I'd
suggest the data.table tag on Stack Overflow (which I subscribe to) :
http://stackoverflow.com/questions/tagged/data.table
Btw, I recently presented at LondonR. Here's a link to the slides :
http://datatable.r-forge.r-project.org/LondonR_2012.pdf
Matthew
--
View this message in context:
http://r.789695.n4.nabble.com/data-table-vs-plyr-reg-output-tp4634518p4634865.html
Sent from the R help mailing list archive at Nabble.com.