Skip to content

at_depth still useful #381

Closed
Closed
@py-b

Description

@py-b

Hello,

Because input and output of modify_depth have now to be the same, some powerful feature was lost.

Let's say we want unique values of data-frame columns stored in a list. With the newest purrr release, we have to repeat map n times, whereas in previous releases, at_depth(n, ...) did the job .

With modify_depth, the result is no more what we expect. Here is an example with only one data.frame in the list :

library(dplyr)

dfs <- list(
  df1 = data.frame(x = c(1, 2), y = c(1, 1))
)

## Expected ##
dfs %>% map(~ .x %>% map(unique)) # <=> at_depth(2, unique) in previous release
#> $df1
#> $df1$x
#> [1] 1 2
#> 
#> $df1$y
#> [1] 1

## Not expected ##
dfs %>% modify_depth(2, unique)
#> $df1
#>   x y
#> 1 1 1
#> 2 2 1

I understand the purpose of modify_depth, but maybe it should not replace at_depth?
(they could coexist?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions