[R] as.xts

Joshua Ulrich josh.m.ulrich at gmail.com
Wed Oct 17 21:51:43 CEST 2012


Hi Chad,

as.xts.data.frame assumes the rownames are timestamps.  Since this
isn't the case for your object, you need to use the xts constructor:

x <- xts(d$total, d$reportDate)

This assumes your data.frame is named 'd' and that the reportDate
column is actually a Date class (not character or factor).

Best,
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com


On Wed, Oct 17, 2012 at 2:15 PM, sf631 <chad.gray at gmail.com> wrote:
> I'm not the original poster, but I do have the same question.
>
> I have pulled in data via RODBC into a data frame, which looks like below
> and I'm getting the same error message:
> /("Error in as.POSIXlt.character(x, tz, ...) :
>   character string is not in a standard unambiguous format")
> /
>
> The date format seems pretty straightforward to me so I'm kind of stuck at
> what to do.  BTW, I'm *very* new to R so please forgive some ignorance here
>
> reportDate    total
> 1 2010-12-31 170609.2
> 2 2011-01-03 170778.0
> 3 2011-01-04 170748.4
> 4 2011-01-05 170599.5
> 5 2011-01-06 170335.0
> 6 2011-01-07 169842.1
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/as-xts-tp3028280p4646499.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.




More information about the R-help mailing list