We’re thrilled to announce the release of purrr 1.2.0! purrr enhances R’s functional programming toolkit with a complete and consistent set of tools for working with functions and vectors.
You can install it from CRAN with:
install.packages("purrr")Overall, this is a pretty unexciting release since it primarily focuses on removing long-deprecated functions. It does, however, include a couple of small performance improvements to predicate functions and a brand new getting started vignette. We also require a newer version of the carrier package for
in_parallel() so that it’s easier to use. You can see a full list of changes in the
release notes.
Lifecycle changes
All functions and arguments that were deprecated in purrr 0.3.0 have now been removed after being deprecated for over 5 years. These include:
%@%accumulate_right()at_depth()cross_d()cross_n()reduce2_right()reduce_right()
All functions that were soft-deprecated in purrr 1.0.0 are now fully deprecated. They will continue to work but will generate a deprecation warning, and will be removed in a future release. This includes:
invoke_*()functionslift_*()functionscross*()functions (usetidyr::expand_grid()instead)prepend()splice()rbernoulli()rdunif()when()update_list()*_raw()functionsvec_depth()
These deprecations help keep purrr focused on its core purpose: facilitating functional programming in R.
map_chr()no longer automatically coerces logical, integer, or double values to strings. Previously, this coercion happened silently, which could mask bugs in your code. Of the four CRAN packages that required fixes due to this change, two of them (50%) were bugs.The predicate functions
every(),some(), andnone()now require that the predicate function.preturns a logical scalar:TRUE,FALSE, orNA. Previously,NAvalues of other types (likeNA_integer_orNA_character_) were allowed.
Minor improvements
Apart from all the breaking changes, there were a couple of small improvements:
every(),some(), andnone()have been optimized and are now significantly faster. They’re now as fast as or faster than the equivalentany(map_lgl())orall(map_lgl())calls, making them the preferred choice for checking predicates across lists.purrr (finally) has a “getting started” vignette at
vignette("purrr").
Easier in_parallel()
In purrr 1.1.0, we introduced
in_parallel() for
parallel processing and we’ve had great feedback from the community so far. But it was clear that we hadn’t made it easy enough to include helper functions or other variables required by your map functions. We’ve updated this behaviour in carrier 0.3.0, which is now required by purrr. Now the following (in your global environment) will work as you expect:
fn <- function(x) helper_fn(x) * 2
helper_fn <- function(x) x + 1
1:5 |> map(in_parallel(\(x) fn(x), fn = fn, helper_fn = helper_fn))Whereas previously, fn() would have been unable to find helper_fn(), this is solved by all functions passed to
in_parallel() now sharing the same environment.
Acknowledgements
We’d like to thank everyone who contributed to this release by filing issues and submitting pull requests. Your feedback and contributions help make purrr better for everyone! @feinleib, @filipemsc, @fwimp, @hadley, @its-gazza, @jcolt45, @jeroenjanssens, @jrwinget, @khusmann, @luisDVA, @MarkPaulin, @Meghansaha, @mtcarsalot, @og2293, @padpadpadpad, @PMassicotte, @shikokuchuo, @steffen-stell, and @wahalulu.