I have a DF BV1, and I have a vector BV2. How could I sum up the V(values) of R(regions) from BV1 when the elments show in both BV1 and BV2.
BV1 = data.frame(R= c("CHL","EGY","ETH","IND","IRN"), V = c(1, 2, 3, 4, 5))
R V
1 CHL 1
2 EGY 2
3 ETH 3
4 IND 4
5 IRN 5
BV2 = c("CHL","IRN","PPP") # "CHL" and "IRN" show in both BV1 and BV2
CHL+IRN=6 in BV1 #For example, I would like to have this result.
As I have 50 regions, it is a quick method to apply for this case?
Aucun commentaire:
Enregistrer un commentaire