On 23/10/2014, 8:56 AM, Robert Sherry wrote:
> I am trying to get the current price of gold for my application. I am
> using the library quantmod. The
> R commands I use are:
> getMetals(c('XAU'), from=Sys.Date(), autoassign = FALSE )
> XAUUSD$XAU.USD[1,1]
>
> I would expect the value in XAUUSD$XAU.USD[1,1] to be a scalar but it
> comes back with a date and a number. All I want is the current value,
> not today's date. How do I just get the value?
That function returns time series objects (of class c("xts", "zoo")).
Use as.numeric() to convert to plain numbers, e.g.
as.numeric(XAUUSD$XAU.USD[1,1])
Duncan Murdoch
______________________________________________
[email protected] 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.