I have some data which has the columns company, amount of donation and party.
I want to have a new list where for each company the sum of donated money, for each party, is listed.
So far I know how to aggregate the "amount" column, if I only have one company
df <- df %>% filter(company == "c1" ) %>% select(amount, party)
test<-aggregate(df$amount, by=list(party=a$party), FUN=sum)
Is there a way not to use a loop function for every company?
Thanks for helping