0

I have this table I am working on. All I need to do is to sum the rows for countries, that is, I should have one row for Afghanistan that sums all the three rows, one row for Albania.... Is there any way I can do it easily on R? I thought of using the group_by function but it ain't getting me anywhere. Your help is appreciated.

enter image description here

AnilGoyal
  • 25,297
  • 4
  • 27
  • 45
  • Iamgine `iris` data, then do it like `iris %>% group_by(Species) %>% summarise(across(everything(), sum))` – AnilGoyal Jun 19 '21 at 13:16
  • In base R: `aggregate(. ~ ref_area.label, data = b[, -2], sum) # removes classif1.label` or if you classif1.label is part of the grouping: `aggregate(. ~ ref_area.label + classif1.label, data = b, sum)` – ngwalton Jun 19 '21 at 13:39

0 Answers0