Hi,
I have the yearly values of exports divided by partners/countries, but I need to aggregate them in regional blocs
For instance, create one group called "Pacific Alliance" composed by Mexico, Colombia, Peru and Chile and another called "Andean Community" (Colombia, Peru, Ecuador and Bolivia). As you can see, in some cases, the same country belongs to more than one bloc. Do you know how to deal with that?
In the end, instead of a column with counties, I should have a column indicating the trade value of Pacific Alliance in 2010 and in 2011 and the same goes for other blocs that I need to create
My reprex is:
data.frame(
Year = c(2011L,2011L,2011L,2011L,2011L,2011L,
2011L,2011L,2011L,2011L,2011L,2011L,2011L,2011L,2011L,
2011L,2011L,2011L,2010L,2010L,2010L,2010L,2010L,2010L,
2010L,2010L,2010L,2010L,2010L,2010L,2010L,2010L,2010L,
2010L,2010L,2010L),
TradeValue = c(663536,305249525,1370308420,2205006468,
40354718,18525637,1908591669,1395268,293072616,704938268,
11219301,12729123,1396866761,776401,66465942,2833496,
22148147,1750409643,674346,130382390,1040262882,906924506,
34583261,2140942,1824535234,1272176,173326030,638214736,
7639368,10267257,1131840170,816590,4195982,2104475,14299677,
1422877052),
Partner = as.factor(c("Antigua and Barbuda",
"Argentina","Brazil","Chile","Cuba","Dominica",
"Ecuador","Grenada","Honduras","Mexico",
"Nicaragua","Paraguay","Peru","Saint Kitts and Nevis",
"Saint Lucia","Saint Vincent and the Grenadines",
"Uruguay","Venezuela","Antigua and Barbuda","Argentina",
"Brazil","Chile","Cuba","Dominica","Ecuador",
"Grenada","Honduras","Mexico","Nicaragua","Paraguay",
"Peru","Saint Kitts and Nevis","Saint Lucia",
"Saint Vincent and the Grenadines","Uruguay",
"Venezuela"))
)
I appreciate your help in advance!