[R-SIG-Finance] passing fraction of seconds in xts object
Brian G. Peterson
brian at braverock.com
Thu Aug 20 14:02:06 CEST 2009
?as.POSIXct
?strftime # for the format string
This topic has been covered so many times on this list that a simple
archive search for 'xts' and 'POSIXct' should have provided enough
pointers if the documentation did not.
your date_time should not be a column in your data but should be the
index of your data
something like:
options(digits.secs=6)
x <- data
x.xts <- xts(x[,"price"],order.by=as.POSIXct(x[,"date_time"],"%y-%m-%d
%H:%M:%OS" ))
Regards,
- Brian
sunil wrote:
> Dear R User, I am creating a xts object for trading data.
> Initially I am passing date_time_stamp and price in xts object as follows
> price
> 12.13
> 12.44
> 12.32
> 12.54
> etc.
> date_time
> "2009-07-23 09:55:01.456"
> "2009-07-23 09:55:01.717"
> "2009-07-23 09:55:02.632"
> "2009-07-23 09:55:02.564"
> etc.
>
> data=xts(price,as.POSIXct(date_time))
> #don't know better way if there any. If I pass the date_stamp without
> as.POSIXct it gives me an error, since date_time is character object.
>
> here data will not have milliseconds part. Any help?
> Suneel
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only.
> -- If you want to post, subscribe first.
>
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list