Skip to content

Adding columns to an XTS

1 message · Robert Nicholson

#
If you're using rollapply with an existing XTS object from getSymbols what's the most appropriate way to add new columns to the object?

say you have

getSymbols('AAPL')
change = rollapply(Cl(AAPL),width=2, function(x) log(x[2]/x[1]), by=1, align = "right", na.pad = TRUE)
colnames(change) <- c('AAPL.change')

how can you get change into the original AAPL xts object whereby everything is lined up correctly?