Functions

match.arg

A weird function that can help you write better functions

Edward Visel

9 minute read

Lately I’ve been working with a lot of people whose first language is not R, which has given me more of an appreciation for R’s oddities. Some in retrospect were probably ill-advised, like partial matching with $:

Anonymous Functions, Not Variables

Use the LHS of a formula to specify variable names in purrr-style lambda functions

Edward Visel

7 minute read

I am a very heavy purrr user. The killer feature is clearly map_df (fairly recently rebranded as map_dfr and map_dfc for row and column binding, respectively) to iterate over a list à la lapply and simplify the result to a data frame. Thanks to the power of dplyr::bind_rows, it fixes all the drawbacks of sapply’s simplify2array behavior: