I have foreign trade data divided by country/year, but I need to sum all the Reporters to get a new value, which will be "South America".
So, in the end, I should have for each year the TradeValue of South America to Australia, Canada, China, etc (Partners).
I have a reprex below:
data.frame(
stringsAsFactors = FALSE,
Year = c(1991,1991,1991,1991,1991,
1991,1991,1991,1991,1991,1991,1991,1991,1991,1991,
1991,1991,1991,1991,1991,1991,1991,1991,1991,
1991,1991,1991,1991,1991,1991,1991,1991,1991,1991,
1991,1991,1991,1991,1991,1991,1991,1991,1991,
1991,1991,1991,1991,1991,1991,1991,1991,1991,1991,
1991,1991,1991,1991,1991,1991,1991,1991,1991,
1991,1991,1991,1991,1991,1991,1991,1991,1991,1991,
1991,1991,1991,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992,1992,1992,
1992,1992,1992,1992,1992,1992,1992),
Reporter = c("Brazil","Chile","Colombia",
"Ecuador","Paraguay","Brazil","Chile","Colombia",
"Ecuador","Paraguay","Brazil","Chile","Colombia",
"Ecuador","Paraguay","Brazil","Chile","Colombia","Ecuador",
"Paraguay","Brazil","Chile","Colombia","Ecuador",
"Paraguay","Brazil","Chile","Colombia","Ecuador",
"Paraguay","Brazil","Chile","Colombia","Ecuador",
"Paraguay","Brazil","Chile","Colombia","Ecuador","Paraguay",
"Brazil","Chile","Colombia","Ecuador","Paraguay",
"Brazil","Chile","Colombia","Ecuador","Paraguay",
"Brazil","Chile","Colombia","Ecuador","Paraguay",
"Brazil","Chile","Colombia","Ecuador","Paraguay","Brazil",
"Chile","Colombia","Ecuador","Paraguay","Brazil",
"Chile","Colombia","Ecuador","Paraguay","Brazil",
"Chile","Colombia","Ecuador","Paraguay",
"Bolivia (Plurinational State of)","Brazil","Chile","Colombia","Ecuador",
"Peru","Bolivia (Plurinational State of)","Brazil",
"Chile","Colombia","Ecuador","Paraguay","Peru",
"Bolivia (Plurinational State of)","Brazil","Chile",
"Colombia","Ecuador","Peru","Bolivia (Plurinational State of)",
"Brazil","Chile","Colombia","Ecuador","Paraguay",
"Peru","Bolivia (Plurinational State of)","Brazil",
"Chile","Colombia","Ecuador","Paraguay","Peru",
"Bolivia (Plurinational State of)","Brazil","Chile","Colombia",
"Paraguay","Peru","Bolivia (Plurinational State of)",
"Brazil","Chile","Colombia","Ecuador","Paraguay",
"Peru","Bolivia (Plurinational State of)","Brazil",
"Chile","Colombia","Ecuador","Paraguay","Peru",
"Bolivia (Plurinational State of)","Brazil","Chile","Colombia",
"Ecuador","Paraguay","Peru",
"Bolivia (Plurinational State of)","Brazil","Chile","Colombia","Ecuador",
"Paraguay","Peru","Bolivia (Plurinational State of)",
"Brazil","Chile","Colombia","Ecuador","Paraguay","Peru",
"Bolivia (Plurinational State of)","Brazil","Chile",
"Colombia","Ecuador","Paraguay","Peru","Brazil","Chile",
"Colombia","Ecuador","Paraguay","Peru",
"Bolivia (Plurinational State of)","Brazil","Chile","Colombia",
"Ecuador","Paraguay","Peru",
"Bolivia (Plurinational State of)","Brazil","Chile","Colombia","Ecuador",
"Paraguay","Peru","Bolivia (Plurinational State of)","Brazil",
"Chile","Colombia","Ecuador","Paraguay","Peru"),
Partner = c("Australia","Australia",
"Australia","Australia","Australia","Canada","Canada",
"Canada","Canada","Canada","China","China","China",
"China","China","France","France","France","France",
"France","Germany","Germany","Germany","Germany",
"Germany","India","India","India","India","India",
"Indonesia","Indonesia","Indonesia","Indonesia","Indonesia",
"Italy","Italy","Italy","Italy","Italy","Japan",
"Japan","Japan","Japan","Japan","Mexico","Mexico",
"Mexico","Mexico","Mexico","Rep. of Korea",
"Rep. of Korea","Rep. of Korea","Rep. of Korea","Rep. of Korea",
"Turkey","Turkey","Turkey","Turkey","Turkey",
"United Kingdom","United Kingdom","United Kingdom",
"United Kingdom","United Kingdom","USA","USA","USA","USA",
"USA","World","World","World","World","World",
"Australia","Australia","Australia","Australia","Australia",
"Australia","Canada","Canada","Canada","Canada",
"Canada","Canada","Canada","China","China","China",
"China","China","China","France","France","France",
"France","France","France","France","Germany","Germany",
"Germany","Germany","Germany","Germany","Germany",
"India","India","India","India","India","India",
"Indonesia","Indonesia","Indonesia","Indonesia",
"Indonesia","Indonesia","Indonesia","Italy","Italy","Italy",
"Italy","Italy","Italy","Italy","Japan","Japan",
"Japan","Japan","Japan","Japan","Japan","Mexico",
"Mexico","Mexico","Mexico","Mexico","Mexico","Mexico",
"Rep. of Korea","Rep. of Korea","Rep. of Korea",
"Rep. of Korea","Rep. of Korea","Rep. of Korea","Rep. of Korea",
"Russian Federation","Russian Federation",
"Russian Federation","Russian Federation","Russian Federation",
"Russian Federation","Russian Federation","Turkey",
"Turkey","Turkey","Turkey","Turkey","Turkey",
"United Kingdom","United Kingdom","United Kingdom",
"United Kingdom","United Kingdom","United Kingdom","United Kingdom",
"USA","USA","USA","USA","USA","USA","USA","World",
"World","World","World","World","World","World"),
TradeValue = c(218912768,27441404,6225037,
1707259,19750,464262208,54218664,80623096,3863359,
83675,226395312,80425792,17249908,38649,3613293,
864403904,388162560,174076960,26088384,11224829,
2157795072,715506624,547410304,136968800,36220492,165651680,
8043120,1433446,5712,21627,198796464,29507986,
4444402,473919,2847511,1352686848,339006144,110004128,
59227224,39323916,2557230080,1677971072,231723664,
62739576,3810567,757917248,44211744,55279904,18738534,
1025552,672131776,270350464,17244088,296872448,
8018309,147786880,17739464,350431,3510437,105672,
1056959232,558879680,189760976,11399010,3802803,6387453440,
1387587072,2823803136,1402672640,35005528,31621120000,
8960062464,7268634624,2851399168,737040576,99388,
206919888,23384686,7786584,1334356,13851797,3343210,
401470240,62851868,55501984,3801285,790413,111656400,
16430,460024576,221297344,3507554,776396,251797408,
32243824,844323456,380851936,128588496,33135612,
14062889,68804600,31681680,2073711232,609494016,
592327936,107913240,20328764,147660208,695350,148693040,
1560390,181986,188572,1820345,297072,136855792,
45968904,240673,195450,2215903,257624,1955013,1597161472,
376975200,127655384,93458240,22486636,193796240,
1628093,2311336192,1714072448,197430480,62416536,
2449286,291650816,6630893,1113647104,90115840,69851224,
33132368,1601389,96924528,328158,571327040,242961680,
13110620,347820480,2633642,58812932,122988,
126059496,34904880,6627143,6728042,202759,5252825,216010688,
18605626,307684,6632587,1230180,3263960,127588432,
1286679680,619276736,186427696,15229376,5336958,
218111472,153707584,7081407488,1581919616,2722496768,
1421556608,34994072,705768960,765313792,35975315456,
9913288704,6916042752,3042286848,656554304,3359371520)
)
I appreciate your help!