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

jim holtman jholtman at gmail.com
Thu May 12 03:47:00 CEST 2011


Depends on what you want to do with the date.  If it is a character
string, then just quote it:

 flex("xx-xx-xxxx","xx-xx-xxxx")

If you want it as a Date or POSIXct object, then convert it:

flex(as.Date('2011-05-01"), as.Date('2011;05-31"))

It all depends on how you are using it in your custom function.  In
either case you still enclose it in quotes.

On Wed, May 11, 2011 at 5:44 PM, MatAra <mateoarana at gmail.com> wrote:
> Hello gentlemen,
>
> This is a great discussion. Thank you all for providing useful answers.
> I am also new to R, was working mostly with SAS before, and have a question
> regarding passing arguments to R functions that are wrapped in quotes.
>
> Using the previous example:
> getSymbols(tickers, from="start", to="end")
>
> Given that "start/end" are quoted, how can I pass a date xx-xx-xxxx to R
> when I am invoking a custom function, like:
>
> flex<- (start, end){
> getSymbols(tickers, from="start", to="end")
> }
> flex(xx-xx-xxxx,xx-xx-xxxx)
>
> I have tried different combinations but I haven't been able to pass the
> correct date, R simply doesn't capture the value. The same issue was
> happening with tickers, although there is a way around the issue, the
> original problem remains....passing an argument that's quoted in the
> function.
>
> Any help would be greatly appreciated!
> Cheers!
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/pass-character-vector-in-instrument-field-of-get-hist-quote-function-tp3350779p3515936.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.
>



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?



More information about the R-help mailing list