NEWS.md

purrr 1.0.2

purrr 1.0.1

purrr 1.0.0

Breaking changes

Core purpose refinements

Mapping

Deprecation next steps

New features

Flattening and simplification

Tidyverse consistency

Plucking

Setting with NULL

list_ functions

Minor improvements and bug fixes

purrr 0.3.5

purrr 0.3.4

purrr 0.3.3

purrr 0.3.2

purrr 0.3.1

purrr 0.3.0

Breaking changes

For instance, the [[<- for data frames is stricter than the [<- method and might throw errors instead of warnings. This is the case when assigning a longer vector than the number of rows. [<- truncates the vector with a warning, [[<- fails with an error (as is appropriate).

This change is meant to detect problems early with a more meaningful error message.

Plucking

Mapping

This is a breaking change for every() and some() which were documented to be more liberal in the values they accepted as logical (any vector was considered TRUE if not a single FALSE value, no matter its length). These functions signal soft-deprecation warnings instead of a hard failure.

Edit (purr 0.4.0): every() and some() never issued deprecation warnings because of a technical issue. We didn't fix the warnings in the end, and using predicates returning NA is no longer considered deprecated. If you need to use every() and some() in contexts where NA propagation is unsafe, e.g. in if () conditions, make sure to use safe predicate functions like is_true().

Rates

slowly() modifies a function so that it waits for a given amount of time between calls.

partial()

The interface of partial() has been simplified. It now supports quasiquotation to control the timing of evaluation, and the rlang::call_modify() syntax to control the position of partialised arguments.

To prevent partial matching of ... on ...f, the latter has been renamed to .f, which is more consistent with other purrr function signatures.

```r # Before partial(fn, u = runif(1), n = rnorm(1), .lazy = FALSE)

# After partial(fn, u = !!runif(1), n = !!rnorm(1)) # All constant partial(fn, u = !!runif(1), n = rnorm(1)) # First constant ```

Minor improvements and fixes

Note that for now you need to import vars() from dplyr or call it qualified like dplyr::vars(). It will be reexported from rlang in a future release.

Life cycle

.dir arguments

We have standardised the purrr API for reverse iteration with a common .dir argument.

```{r} # Before: reduce_right(1:3, f)

# After: reduce(1:3, f, .dir = "backward") ```

Note that the details of the computation have changed. Whereas reduce_right() computed f(f(3, 2), 1), it now computes f(1, f(2, 3)). This is the standard way of reducing from the right.

To produce the exact same reduction as reduce_right(), simply reverse your vector and use a left reduction:

```{r} # Before: reduce_right(1:3, f)

# After: reduce(rev(1:3), f) ```

```{r} # Before: accumulate_right(1:3, f)

# After: accumulate(1:3, f, .dir = "backward") ```

```{r} # Before detect(x, f, .right = TRUE)

# After detect(x, f, .dir = "backward") ```

Simplification of partial()

The interface of partial() has been simplified (see more about partial() below):

Retirement of invoke()

invoke() and invoke_map() are retired in favour of exec(). Note that retired functions are no longer under active development, but continue to be maintained undefinitely in the package.

```r # Before: invoke(mean, list(na.rm = TRUE), x = 1:10)

# After exec(mean, 1:10, !!!list(na.rm = TRUE)) ```

Note that retired functions are not removed from the package and will be maintained undefinitely.

```r # Before: invoke_map(fns, list(args)) invoke_map(fns, list(args1, args2))

# After: map(fns, exec, !!!args) map2(fns, list(args1, args2), function(fn, args) exec(fn, !!!args)) ```

Other lifecycle changes

```{r} # Before: list_modify(x, foo = NULL)

# After:
list_modify(x, foo = zap())

```

This change is motivated by the ambiguity of NULL as a deletion sentinel because NULL is also a valid value in lists. In the future, NULL will set an element to NULL rather than removing the element.

purrr 0.2.5

purrr 0.2.4

purrr 0.2.3

Breaking changes

We noticed the following issues during reverse dependencies checks:

Dependencies

purrr no longer depends on lazyeval or Rcpp (or dplyr, as of the previous version). This makes the dependency graph of the tidyverse simpler, and makes purrr more suitable as a dependency of lower-level packages.

There have also been two changes to eliminate name conflicts between purrr and dplyr:

pluck()

The plucking mechanism used for indexing into data structures with map() has been extracted into the function pluck(). Plucking is often more readable to extract an element buried in a deep data structure. Compare this syntax-heavy extraction which reads non-linearly:

accessor(x[[1]])$foo

to the equivalent pluck:

x %>% pluck(1, accessor, "foo")

Map helpers

as_mapper() sanitises primitive functions by transforming them to closures with standardised argument names (using rlang::as_closure()). For instance + is transformed to function(.x, .y) .x + .y. This results in proper argument matching so that map(1:10, partial(-, .x = 5)) produces list(5 - 1, 5 - 2, ...).

Map functions

Modify functions

A new modify() family returns the same output of the type as the input .x. This is in contrast to the map() family which always returns a list, regardless of the input type.

The modify functions are S3 generics. However their default methods should be sufficient for most classes since they rely on the semantics of [<-. modify.default() is thus a shorthand for x[] <- map(x, f).

New functions

Minor improvements and bug fixes

purrr 0.2.2.1

This is a compatibility release with dplyr 0.6.0.

purrr 0.2.2

purrr 0.2.1

purrr 0.2.0

New functions

Row based functionals

We are still figuring out what belongs in dplyr and what belongs in purrr. Expect much experimentation and many changes with these functions.

Bug fixes and minor changes

Deprecated functions



Try the purrr package in your browser

Any scripts or data that you put into this service are public.

purrr documentation built on Aug. 10, 2023, 9:08 a.m.