Does replyr::let work with data.table?

December 24, 2016
By

[This article was first published on R – Win-Vector Blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I’ve been asked if the adapter “let” from our R package replyr works with data.table.

My answer is: it does work. I am not a data.table user so I am not the one to ask if data.table benefits a from a non-standard evaluation to standard evaluation adapter such as replyr::let.

Using replyr::let with data.table looks like the following:

library("data.table")
library("replyr")

data("iris", package= "datasets")
iris.dt <- data.table(iris)

# non-standard evaluation, column names hard-coded
iris.dt[, mean(Sepal.Length), by=Species]

# standard evaluation, column names parameterized
let(
    list(GROUPCOL='Species', DATACOL='Sepal.Length'),
    iris.dt[, mean(DATACOL), by=GROUPCOL]
   )

I’ve generated some timings to show there is some overhead in the translation (especially on trivial examples):

Pressure 1

If any data.table users want to comment if this is useful or not, I’d be happy to hear from you.

To leave a comment for the author, please follow the link and comment on their blog: R – Win-Vector Blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)