Skip to content

New family to replace summarise_each/mutate_each #1845

@hadley

Description

@hadley
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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions