Why use purrr::map instead of lapply?

If the only function you’re using from purrr is map(), then no, the advantages are not substantial. As Rich Pauloo points out, the main advantage of map() is the helpers which allow you to write compact code for common special cases: ~ . + 1 is equivalent to function(x) x + 1 (and \(x) x … Read more

What is meaning of first tilde in purrr::map

As per the map help documentation, map needs a function but it also accepts a formula, character vector, numeric vector, or list, the latter of which are converted to functions. The ~ operator in R creates formula. So ~ lm(mpg ~ wt, data = .) is a formula. Formulas are useful in R because they … Read more