0
china_map2<-china_map  %>% group_by(Country) %>% mutate(sum=sum(ODA)) 

I am trying to add the value by country, but I keep getting the overall sum of all countries. I would like to get the sum value for each country, but I get one result adding all values. Can someone help with this problem?

lim
  • 1
  • 1
  • 1
    Please [make this question reproducible](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) by including example data (some or all of `china_map`) in a plain text format - for example the output from `dput(china_map)`, or `dput(head(china_map, 20))`. I have to point out that the name of the variable suggests it may contain only one country :) – neilfws Mar 15 '21 at 04:11
  • Try using `china_map2<-china_map %>% group_by(Country) %>% dplyr::mutate(sum=sum(ODA)) ` – Ronak Shah Mar 15 '21 at 04:15

0 Answers0