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

New family to replace summarise_each/mutate_each #1845

Closed
hadley opened this issue May 20, 2016 · 4 comments
Closed

New family to replace summarise_each/mutate_each #1845

hadley opened this issue May 20, 2016 · 4 comments
Milestone

Comments

@hadley
Copy link
Member

@hadley hadley commented May 20, 2016

by_cyl <- mtcars[1:5] %>% group_by(cyl)
by_cyl %>% summarise_all(mean)
by_cyl %>% summarise_if(is.numeric, mean)
by_cyl %>% summarise_at(cols(cyl, mpg, wt), funs(mean, median), na.rm = TRUE)

by_cyl %>% mutate_all(scale)
by_cyl %>% mutate_if(is.numeric, scale)
by_cyl %>% mutate_at(cols(cyl, mpg, wt), funs(scale, rescale01))
by_cyl %>% mutate_at(c("cyl", "mpg", "wt"), funs(scale, rescale01))

summarise_each() and mutate_each() would be deprecated in favour of this new approach. And this would replace (e.g) purrrr::dmap().

And cols would be something along the lines of:

cols <- function(...) eval(subsitute(alist(...)))

(but with a special class)

@hadley
Copy link
Member Author

@hadley hadley commented May 20, 2016

@lionel- would this be a complete replacement for the current purrr functions that work with rows/dataframes? Or would there still be somethings that you couldn't do?

Loading

@lionel-
Copy link
Member

@lionel- lionel- commented May 23, 2016

would this be a complete replacement for the current purrr functions that work with rows/dataframes?

Yes, expect for column collation, which is probably not that important.

And list collation would be handled with tidyr::nest() + dplyr::mutate() + purrr::map() if you want to remove by_slice() from purrr as well.

Loading

@lionel-
Copy link
Member

@lionel- lionel- commented May 23, 2016

do you need me to take a look at this @hadley?

Loading

@hadley
Copy link
Member Author

@hadley hadley commented May 23, 2016

Yes, that would be great!

Loading

lionel- added a commit to lionel-/dplyr that referenced this issue May 24, 2016
@hadley hadley added this to the 0.5 milestone May 26, 2016
lionel- added a commit to lionel-/dplyr that referenced this issue May 27, 2016
@hadley hadley closed this in 7385813 May 31, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants