I am trying to pull multiple Quandl codes at the same time into R, and want to end up with a single xts object with [i] columns (plus the date column) containing the data.
The function I created to call the data from Quandl seems okay, but I need help with the syntax to create a xts object. Here is what I have so far:
# Build vector of model holdings
holdings <- c("VTI","VEA","VWO","LQD","BND","TLT","VNQ","GLD","VGSH")
# Function to fetch each holding as an xts object, adjusted close returns
getQholdings <- function(ticker){
codes <- paste("EOD/",ticker,".11",sep="")
for(i in 1:length(ticker)){
???? <- Quandl(codes[i],type="xts",transformation="rdiff",
start_date="2013-12-31",collapse="monthly",
force_irregular=TRUE)
}}
I need help where the question marks are, which I assume should be some kind of function to build a xts object progressively with each iteration of the "for" function.