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'),
'v1'=c(1,2,3,1,2,3,6),
'v1p'=c('33.33%','66.67%','100.00%','33.33%','66.67%','100.00%',''),
v2=c(2,3,5,4,5,9,14),
'v2p'=c('40.00%','60.00%','100.00%','44.44%','55.56%','100.00%',''))
adorn_totals function seems be able to do it but cannot work for subgroup.
any idea to solve the problem will be appreciated. Thanks.
Best,
Veda