I have an xts object with multiple columns of the same type. I have another xts object with integers that correspond to column positions in the first object. I would like to generate an third xts object that contains one column representing the value of the column indicated by the corresponding index. For example:
# xts.1:
2003-07-30 17:00:00 0.2015173 0.10159303 0.19244332 0.08138396
2003-08-28 17:00:00 0.1890154 0.06889412 0.12700216 0.04631253
2003-09-29 17:00:00 0.1336947 0.08023267 0.09167604 0.02376319
2003-10-30 16:00:00 0.1713496 0.13324238 0.11427968 0.05946272
# xts.2:
2003-07-30 17:00:00 1
2003-08-28 17:00:00 4
2003-09-29 17:00:00 2
2003-10-30 16:00:00 3
# Desired result:
2003-07-30 17:00:00 0.2015173
2003-08-28 17:00:00 0.04631253
2003-09-29 17:00:00 0.08023267
2003-10-30 16:00:00 0.11427968
I feel like I'm missing something very elementary about how to do this but, if so, it's escaping me at the moment.