New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

`at_depth` still useful #381

Closed
the-knife opened this Issue Sep 6, 2017 · 3 comments

Comments

Projects
None yet
4 participants
@the-knife
Copy link

the-knife commented Sep 6, 2017

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?)

@lmwang9527

This comment has been minimized.

Copy link

lmwang9527 commented Sep 14, 2017

I have another use case for at_depth that is not fulfilled by modify_depth: #363

@lionel-

This comment has been minimized.

Copy link
Member

lionel- commented Sep 15, 2017

We could restore it as map_depth()?

@the-knife

This comment has been minimized.

Copy link

the-knife commented Sep 17, 2017

Would be great !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment