adorn_totals for each subgroup

Hi R experts,

I have a data frame like this ori=data.frame(g=c('a','a','b','b'),v1=c(1,2,1,2),v2=c(2,3,4,5))
Want to create sum and percenatge for 'v1' and 'v2' grouped by 'g'
Here is the result
res=data.frame('g'=c('a','a','a.totoal' ,'b','b','b.totoal' ,'totoal'),
adorn_totals function seems be able to do it but cannot work for subgroup.
any idea to solve the problem will be appreciated. Thanks.


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.