[R] as.xts

Joshua Wiley jwiley.psych at gmail.com
Fri Nov 5 17:02:39 CET 2010


Hi Ela,

as.xts() calls as.POSIXlt() to convert the dates to a date/time class.
 Evidently, the the column that contains your times is not
"unambiguous" to POSIX, that is, the format is not clear.  It is
really impossible to give you much more advice without having some
sample data or what you actually tried.

If you did not specify the "order.by" argument, by default,
as.xts.data.frame() will try the rownames, but these are almost
certainly not in any readable format.  Further, even if you tell it
which column has your times, they need to be in a known format:
‘Date’, ‘POSIXct’, ‘timeDate’, as well as ‘yearmon’ and ‘yearqtr’

Things that would help:

1) provide a small example dataset that mimics your own and
illustrates your problem.  If this is unfeasible, at least provide
str(yourdata)
2) include the code you tried that lead to the error

Without more, my best suggestion is to read:

?xts
?as.xts.data.frame
?as.POSIXct
?as.Date

and depending how familiar you are with R, look at the code from:
getAnywhere(as.xts.data.frame)


HTH,

Josh

On Fri, Nov 5, 2010 at 1:28 AM, spela podgorsek <spelca27 at gmail.com> wrote:
> hey
>
> I am trying to turn a dataframe into xts with the function:
> as.xts,
> but it returns the error:
>
> Error in as.POSIXlt.character(x, tz, ...) :
> character string is not in a standard unambiguous format
>
> could someone give me some pointers please
>
> the data is coming from a spreadsheet via the excel, and has 5 columns
> of data (date (with the date and time), open, high, low, close) (excel
> format)
>
> ela
>
> ______________________________________________
> 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.
>



-- 
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/



More information about the R-help mailing list