Skip to content

quantmod: dailyReturn on a list of variables

2 messages · patzoul, Jeff Ryan

#
I run the following code:
myAssets <- c("STOXX50E", "GSPC", "N225")
nbAssets <- NROW(myAssets)
myIndices <- paste("^", myAssets, sep="")
getSymbols(myIndices)

I would then like to apply the dailyReturn function on the 3 sets of data
that I loaded.

If I do dailyReturn(myAssets[1]) I get an error message.

What do I need to change?
#
nbAssets in your code is simply the number 3.

Try:

myRet <- sapply(list(STOXX50E,GSPC,N225), dailyReturn)
cbind(myRet[[1]], myRet[[2]], myRet[[3]])

HTH
Jeff
On Wed, Nov 5, 2008 at 4:08 PM, patzoul <patzoul at free.fr> wrote: