I have a time series object suppose :
library(xts)
exposure <- xts(Google = c(100, 200,300,400,500,600,700,800),
Apple = c(10, 20,30,40,50,60,70,80),
Audi = c(1,2,3,4,5,6,7,8),
BMW = c(1000, 2000,3000,4000,5000,6000,7000,8000),
AENA = c(50,51,52,53,54,55,56,57,58),
order.by = Sys.Date() - 1:8)
I have a dataframe :
map <- data.frame(Company = c("Google", "Apple", " Audi", "BMW", " AENA"),
Country = c("US", "US", " GERMANY", "GERMANY", " SPAIN"))
I want to aggregate in exposure object based on the country to which the companies are mapped. Basically my output will be a xts object with same index as exposure but column names would be that of US, GERMANY, SPAIN. For example for a particular date under US column I would want sum of exposures for Google and Apple for that date.
Any help is welcome.