[R-SIG-Finance] non-standard time-format conversion from data.frame to xts

Brian G. Peterson brian at braverock.com
Wed Dec 8 15:33:58 CET 2010


Didn't I just get done suggesting that you construct a self-contained 
example?

Having different dates in different files is fine.  You still *know* 
what the date is when you load it in.  There are lots of options here.

One would be to paste() the date (that you know when loading) and the 
Time column together, then usinga full format string, as described in 
?strftime.

You'll have to do some work, but you'll have an answer.
\
    - Brian


On 12/08/2010 08:29 AM, Andres Susrud wrote:
> Hi thanks for answer, I really don't need the date because I have the
> different dates in different files.
>
> the errormessage I get is the following:
> Error in as.POSIXlt.character(x, tz, ...) :
>    character string is not in a standard unambiguous format
>
> BR
>
> Andres
>
> On Wed, Dec 8, 2010 at 3:24 PM, Brian G. Peterson <brian at braverock.com
> <mailto:brian at braverock.com>> wrote:
>
>     On 12/08/2010 08:02 AM, Andres Susrud wrote:
>
>         Hi,
>
>         I have a conversion problem from data.frame to xts.
>
>         my dataset looks like this
>
>             data[1:5,]
>
>                  Time   Bid  Offer
>         1 7:10:03 AM 6118.5 6119.5
>         2 7:10:36 AM 6118.5 6119.5
>         3 7:11:07 AM 6119.5 6119.5
>         4 7:11:48 AM 6119.0 6120.0
>         5 7:12:25 AM 6119.0 6119.5
>
>         Because of the lack of date, and the time format of H,M,S and
>         AM/PM, I can't
>         convert via as.xts or as.zoo etc.
>
>         any suggestions?
>
>
>     I assume that you know the date...
>
>     given that, you will change your format string (see ?strftime )
>     to something like
>
>     format='2010-12-08 %I:%M:%S %p'
>
>     Next time, please use dput() for your example data, and construct a
>     self-contained example.
>
>     Regards,
>
>       - Brian
>
>     --
>     Brian G. Peterson
>     http://braverock.com/brian/
>     Ph: 773-459-4973
>     IM: bgpbraverock
>
>


-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list