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

A proposal for appending totals in summarise #316

Open
joselao opened this issue Oct 16, 2020 · 1 comment
Open

A proposal for appending totals in summarise #316

joselao opened this issue Oct 16, 2020 · 1 comment

Comments

@joselao
Copy link

joselao commented Oct 16, 2020

A proposal, add bind_rows(), or similar to the tools to get totals easily. i.e.:

mtcars %>%
    # convert cyl column as.character
    mutate_at("cyl",as.character) %>%
    # append a copy of the original mtcars with cyl column = 'TOTAL'
    bind_rows(mutate(mtcars, cyl="total")) %>%
    group_by(cyl) %>% summarise(mpg=mean(mpg)) %>% as.data.frame

To get the final row "total":

    cyl      mpg
1     4 26.66364
2     6 19.74286
3     8 15.10000
4 total 20.09062
@xiaodaigh
Copy link
Collaborator

Yeah. One has to think about how to do this in disk.frame you can just group by, summarise, collect and then and then apply the same.

bind_rows is possible with rbindlist.disk.frame

Perhaps bind_rows needs to be added.

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

No branches or pull requests

2 participants