wrapr::let()

[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 would like to once again recommend our readers to our note on wrapr::let(), an R function that can help you eliminate many problematic NSE (non-standard evaluation) interfaces (and their associate problems) from your R programming tasks.

The idea is to imitate the following lambda-calculus idea:

let x be y in z := ( λ x . z ) y

The above reads as: “let x be y in z” is taken to mean “evaluate the expression z, with the value y substituted in for any instances of x in the expression z.” Notationally: λ builds a function evaluating the expression z with x as a parameter, and the right-placement of y denotes evaluating this function with the argument x set to the value referred to by y.

Now R isn’t the lambda-calculus (and doesn’t have a full-power macro system), so there are a number of details one needs to get right about code quoting/capture and what environment things are evaluated in. wrapr::let() has tools for this, and these tools are documented with examples in the note.

We think wrapr::let() is a good solution (and remains better than some of the systems that come after it; we’ve been attempting to collect notes on prior art and posterior art here, as citing prior art was at one time the standard of discourse).

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.

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)