Posted on Categories Opinion, ProgrammingTags , , ,

wrapr::let()

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).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.