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

Should accumulate and accumulate_right keep names of the input? #446

Closed
AshesITR opened this issue Jan 22, 2018 · 1 comment
Closed

Should accumulate and accumulate_right keep names of the input? #446

AshesITR opened this issue Jan 22, 2018 · 1 comment

Comments

@AshesITR
Copy link
Contributor

@AshesITR AshesITR commented Jan 22, 2018

I was quite surprised to see that accumulate_right and accumulate do not keep the names of the input list.
For my case it makes perfect sense to do so, because I am aggregating along a hierarchy.

Maybe there should be an argument to accumulate(_right) for keeping the names?
For compatibility it might be like this:

l %<>% accumulate(myfun) -> no names
l %<>% accumulate(myfun, .keep_names = TRUE) -> leaves names(l) untouched

Currently I work around this with
l %<>% {set_names(accumulate(., myfun), names(.)) wich is somewhat clunky.

I could submit a PR with the necessary changes if desired.

@hadley
Copy link
Member

@hadley hadley commented Feb 4, 2018

A PR would be great!

AshesITR added a commit to AshesITR/purrr that referenced this issue Feb 6, 2018
Implement tidyverse#446.
Maybe `.keep_names = TRUE` is a better default?
`.keep_names = FALSE` as default matches the original behaviour, but I can hardly imagine code relying on the fact that `accumulate(...)` is unnamed.
AshesITR added a commit to AshesITR/purrr that referenced this issue Feb 7, 2018
AshesITR added a commit to AshesITR/purrr that referenced this issue Feb 9, 2018
@hadley hadley closed this in b3c29c8 Feb 16, 2018
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
2 participants