[R] R-help Digest, Vol 93, Issue 5

Joshua Ulrich josh.m.ulrich at gmail.com
Fri Nov 5 15:05:49 CET 2010


On Fri, Nov 5, 2010 at 6:00 AM,  <r-help-request at r-project.org> wrote:
> Send R-help mailing list submissions to
>        r-help at r-project.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>        https://stat.ethz.ch/mailman/listinfo/r-help
> or, via email, send a message with subject or body 'help' to
>        r-help-request at r-project.org
>
> You can reach the person managing the list at
>        r-help-owner at r-project.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of R-help digest..."
>
>
> Message: 121
> Date: Fri, 5 Nov 2010 09:28:51 +0100
> From: spela podgorsek <spelca27 at gmail.com>
> To: r-help at r-project.org
> Subject: [R] as.xts
> Message-ID:
>        <AANLkTinu6A-Y3O9Jw+jHypRAD+1tsRHZunNoWWu295XC at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> 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
>

as.xts.data.frame expects the rownames of the data.frame to contain
the dates/times.  It would probably be easier to use the xts
constructor on your data.frame:

xData <- xts(Data[,-1],Data[,1])  # assumes "date" in first column

You will need to ensure that Data[,"date"] is a time-based class (e.g.
Date, POSIXt).  If it is character, you will need to convert it to a
time-based class before calling xts().

Best,
--
Joshua Ulrich  |  FOSS Trading: www.fosstrading.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.
>
> End of R-help Digest, Vol 93, Issue 5
> *************************************
>



More information about the R-help mailing list