dplyr: Grand Totals

665 views
Skip to first unread message

BHM

unread,
Jan 25, 2014, 11:43:04 AM1/25/14
to manip...@googlegroups.com
Hi,

First and foremost, dplyr improves, what all ready seemed magic. A lot of appreciation is definitely due.

A simple example:
# ``````````````````````````````````````````````````````````````````
customer = 1:3
profit = c(10,40,20)
df.1 = data.frame(cus = customer, pro = profit)


df.2 = df.1 %.%
mutate (cum.p = cumsum(pro), per.t.pro = round(cum.p / sum(cum.p),2))
# ``````````````````````````````````````````````````````````````````


gives:

cus pro cum.p per.t.pro
1    10   10      0.08
2    40   50      0.38
3    20   70      0.54

Question:
Is it possible to have grand totals at the bottom , or at the right most.

For e.g. a row at the bottom giving all the totals, something as follows:

cus pro cum.p per.t.pro
1    10   10      0.08
2    40   50      0.38
3    20   70      0.54
      70   70      1.00




// Cheers

Hadley Wickham

unread,
Jan 27, 2014, 1:36:19 PM1/27/14
to BHM, manipulatr
It's not currently possible, but I've added it to the do list:
https://github.com/hadley/dplyr/issues/218

Hadley
> --
> You received this message because you are subscribed to the Google Groups
> "manipulatr" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to manipulatr+...@googlegroups.com.
> To post to this group, send email to manip...@googlegroups.com.
> Visit this group at http://groups.google.com/group/manipulatr.
> For more options, visit https://groups.google.com/groups/opt_out.



--
http://had.co.nz/

Burhan ul haq

unread,
Jan 27, 2014, 11:02:01 PM1/27/14
to Hadley Wickham, manipulatr
Great, thanks.


// Cheers 
Reply all
Reply to author
Forward
0 new messages