Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

How to aggregate over multiple variables

$
0
0

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


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>