-
Recursive index via
as_function()
now returnsmissing
when first element isNULL
-
When indexing elements (e.g.
map(x, "field")
),NULL
values are replaced with.null
(#231).
-
Fix for dev tibble support.
-
as_function()
now supports list arguments which allow recursive indexing using either names or positions. They now always stop when encountering the first NULL (#173). -
accumulate
andreduce
correctly pass extra arguments to the worker function.
-
as_function()
gains a.null
argument that for character and numeric values allows you to specify what to return for null/absent elements (#110). This can be used with any map function, e.g.map_int(x, 1, .null = NA)
-
as_function()
is now generic. -
New
is_function()
that returnsTRUE
only for regular functions. -
Fix crash on GCC triggered by
invoke_rows()
.
-
There are two handy infix functions:
x %||% y
is shorthand forif (is.null(x)) y else x
(#109).x %@% "a"
is shorthand forattr(x, "a", exact = TRUE)
(#69).
-
accumulate()
has been added to handle recursive folding. It is shortand forReduce(f, .x, accumulate = TRUE)
and follows a similar syntax toreduce()
(#145). A right-hand versionaccumulate_right()
was also added. -
map_df()
row-binds output together. It's the equivalent ofplyr::ldply()
(#127) -
flatten()
is now type-stable and always returns a list. To return a simpler vector, useflatten_lgl()
,flatten_int()
,flatten_dbl()
,flatten_chr()
, orflatten_df()
. -
invoke()
has been overhauled to be more useful: it now works similarly tomap_call()
when.x
is NULL, and hencemap_call()
has been deprecated.invoke_map()
is a vectorised complement toinvoke()
(#125), and comes with typed variantsinvoke_map_lgl()
,invoke_map_int()
,invoke_map_dbl()
,invoke_map_chr()
, andinvoke_map_df()
. -
transpose()
replaceszip2()
,zip3()
, andzip_n()
(#128). The name more clearly reflects the intent (transposing the first and second levels of list). It no longer has fields argument or the.simplify
argument; instead use the newsimplify_all()
function. -
safely()
,quietly()
, andpossibly()
are experimental functions for working with functions with side-effects (e.g. printed output, messages, warnings, and errors) (#120).safely()
is a version oftry()
that modifies a function (rather than an expression), and always returns a list with two components,result
anderror
. -
list_along()
andrep_along()
generalise the idea ofseq_along()
. (#122). -
is_null()
is the snake-case version ofis.null()
. -
pmap()
(parallel map) replacesmap_n()
(#132), and has typed-variants suffixedpmap_lgl()
,pmap_int()
,pmap_dbl()
,pmap_chr()
, andpmap_df()
. -
set_names()
is a snake-case alternative tosetNames()
with stricter equality checking, and more convenient defaults for pipes:x %>% set_names()
is equivalent tosetNames(x, x)
(#119).
We are still figuring out what belongs in dplyr and what belongs in purrr. Expect much experimentation and many changes with these functions.
-
map()
now always returns a list. Data frame support has been moved tomap_df()
anddmap()
. The latter supports sliced data frames as a shortcut for the combination ofby_slice()
anddmap()
:x %>% by_slice(dmap, fun, .collate = "rows")
. The conditional variantsdmap_at()
anddmap_if()
also support sliced data frames and will recycle scalar results to the slice size. -
map_rows()
has been renamed toinvoke_rows()
. As other rows-based functionals, it collates results inside lists by default, but with column collation this function is equivalent toplyr::mdply()
. -
The rows-based functionals gain a
.to
option to name the output column as well as a.collate
argument. The latter allows to collate the output in lists (by default), on columns or on rows. This makes these functions more flexible and more predictable.
-
as_function()
, which converts formulas etc to functions, is now exported (#123). -
rerun()
is correctly scoped (#95) -
update_list()
can now modify an element calledx
(#98). -
map*()
now use custom C code, rather than relying onlapply()
,mapply()
etc. The performance characteristcs are very similar, but it allows us greater control over the output (#118). -
map_lgl()
now has second argument.f
, not.p
(#134).
-
flatmap()
-> usemap()
followed by the appropriateflatten()
. -
map_call()
->invoke()
. -
map_n()
->pmap()
;walk_n()
->pwalk()
. -
map3(x, y, z)
->map_n(list(x, y, z))
;walk3(x, y, z) ->
pwalk(list(x, y, z))`