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

From: algotr8der <algotr8der_at_gmail.com>
Date: Sat, 12 Mar 2011 12:08:41 -0800 (PST)


I am new to R so I apologize if my question is trivial. I have not been able to figure out whether what I want to do is even possible.

I have a data frame of stock ticker symbols which I store into R space from a txt file as follows:

tickers <- read.csv("stocks.txt", header=FALSE, sep=",") tickers <- tickers[1] / the tickers are stored in the first column

> tickers

    V1
1 BCSI
2 WBSN
3 NTAP
4 FFIV
5 SU

> is.vector(tickers)

[1] FALSE
>
> is.data.frame(tickers)

[1] TRUE I tried to do the following without success.

stockdata <- data.frame()
stockdata <- coredata(get.hist.quote(instruments=tickers,
start="2011-01-01", end="2011-01-31", quote=c("Close"), provider="yahoo")) 

Error in get.hist.quote(instruments = tickers, start = "2011-01-01", end = "2011-01-31", :
  unused argument(s) (instruments = tickers)

So I coerced the data stored in 'tickers' to be a character as follows:

> as.character(tickers)

Then I tried to execute get.hist.quote as above with the same erro.

stockdata <- coredata(get.hist.quote(instruments=tickers, start="2011-01-01", end="2011-01-31", quote=c("Close"), provider="yahoo"))

Error in get.hist.quote(instruments = tickers, start = "2011-01-01", end = "2011-01-31", :
  unused argument(s) (instruments = tickers)

I dont want to use loops because of inefficiencies. I know in Matlab I can take advantage of the matrix/vector environment by passing a variable as a vector. I think there should be a clean way to do what I want to do. I have 1500+ tickers and I dont want to cycle through each of them in a loop.

I would greatly appreciate some guidance.

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

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Sat 12 Mar 2011 - 21:41:06 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 12 Mar 2011 - 22:10:21 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive