[R] pass character vector in instrument field of get.hist.quote function

algotr8der algotr8der at gmail.com
Wed Apr 6 17:16:39 CEST 2011


Hi Joshua,

Thank you for showing me how to use the getSymbols function. So I tried the
following without success - 

> tickers
 [1] "SPY" "DIA" "IWM" "SMH" "OIH" "XLY" "XLP" "XLE" "XLI" "XLB" "XLK" "XLU"
"XLV"
[14] "QQQ"
> str(tickers)
 chr [1:14] "SPY" "DIA" "IWM" "SMH" "OIH" "XLY" "XLP" "XLE" ...

> ClosePrices <- do.call(merge, lapply(tickers,myX,start="2001-03-01",
> end="2011-03-11"), Cl(get(myX)))

Error in get(myX) : invalid first argument

The code for function myX is as follows:

myX <- function(tickers, start, end) {
require(quantmod) 
getSymbols(tickers, from=start, to=end)
}

I'm not sure why you are using the Cl(get(x)) function in your do.call
invocation. I greatly appreciate some guidance.

Thank you

--
View this message in context: http://r.789695.n4.nabble.com/pass-character-vector-in-instrument-field-of-get-hist-quote-function-tp3350779p3431001.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list