I have data that looks like this:
NAME TYPE REP PRODUCT1 PRODUCT2 ... PRODUCT30
Name1 Wholesale HA 4500.00 0.00 ... 760.00
Name2 Retail BM 89.00 0.00 ... 0.00
Name3 Wholesale HA 1000.00 800.00 ... 0.00
Name4 Wholesale BM 3000.00 100.00 ... 0.00
Name5 Wholesale BM 2000.00 0.00 ... 0.00
I want to create a summary table that has the total sales of PRODUCT1 thru PRODUCT30 for each REP and TYPE. So, the result would be this
REP TYPE TOTAL1 TOTAL2 ... TOTAL30
HA Wholesale 5500.00 800.00 760.00
BM Retail 89.00 0.00 0.00
BM Wholesale 5000.00 100.00 0.00
I have tried different variations of the code below to no avail
groupedsales <- group_by(sales, REP, TYPE) %>% summarise_all(sum())
I know that I can get it to work by using
groupedsales <- group_by(sales, REP, TYPE) %>% summarise(TOTAL1=sum(PRODUCT1), TOTAL2=sum(PRODUCT2), ... TOTAL30=sum(PRODUCT30)
But I am thinking there must be an easier way to just get a sum of every column. Please help!