Skip to content
Back to formatted view

Raw Message

Message-ID: <1302102999173-3431001.post@n4.nabble.com>
Date: 2011-04-06T15:16:39Z
From: S
Subject: pass character vector in instrument field of get.hist.quote function
In-Reply-To: <AANLkTi=MudabWyWowA8cg0kT=J5AbkdfXQqrBu2J3+mu@mail.gmail.com>

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.