Skip to content
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
py-b opened this issue Sep 6, 2017 · 3 comments
Closed

at_depth still useful #381

py-b opened this issue Sep 6, 2017 · 3 comments

Comments

@py-b
Copy link

@py-b py-b 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
Copy link

@lmwang9527 lmwang9527 commented Sep 14, 2017

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

@lionel-
Copy link
Member

@lionel- lionel- commented Sep 15, 2017

We could restore it as map_depth()?

@py-b
Copy link
Author

@py-b py-b 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants