I have many large xts
objects in my workspace that i am trying to combine by using cbind
, merge
, apply
or even in a loop. Currently, the xts
data is tick data and cannot paste it here because of its length. However, what I am trying to do is:
cbind(AAPL.O, AMZN.O, BIDU.O, GLD.A, ...) -> all
by pasting using the following names on cbind
stock1 <- c("AAPL.O", "AMZN.O", "BIDU.O", "GLD.A", ...) # names of xts objects
# However this only combines the names "AAPL.O" & "AMZN.O"
cbind(paste(stock1[1]), paste(stock1[2]))
I have also tried apply
:
apply(t(stock1), 2, cbind)
but it only combines the names as in stock1
. I have also tried using:
merge(SPY.A, source [stock1])
but get the following error:
Error in source[stock1] : object of type 'closure' is not subsettable
Since I can't put all the tick data in here I will provide some code to download data from online using getSymbols()
library(quantmod)
symbols <- c("AAPL", "AMZN", "BIDU", "GLD")
getSymbols(symbols)
#These will yield the same problem I am having
cbind(paste(symbols[1]),paste(symbols[2] ))
apply(t(symbols), 2, cbind)
merge(AAPL, source [symbols])