[R-SIG-Finance] convert ordered but non-unique csv to unique xts

Joshua Ulrich josh.m.ulrich at gmail.com
Thu May 9 23:07:35 CEST 2013


Use make.index.unique after you've created an xts object from the data
in the CSV.
--
Joshua Ulrich  |  about.me/joshuaulrich
FOSS Trading  |  www.fosstrading.com

R/Finance 2013: Applied Finance with R  | www.RinFinance.com


On Thu, May 9, 2013 at 4:00 PM, dae <dougedmunds at gmail.com> wrote:
> The csv file has ordered data but does not provide microseconds.
> There are entries with the same datetime  (to the seconds level) which
> are in the proper sequential order.
>
> I want to convert the file into an xts object with unique time values
> (by adding microseconds), if that can be done.
> I am stuck for what steps to take, starting from the csv file.
>
> Example data from csv file (note that four entries all have same datetime):
>
> Time,High,Low,Open,Close,Vol
> 2013/05/08 08:02:04,6.35,6.345,6.35,6.345,172
> 2013/05/08 08:02:07,6.345,6.3425,6.345,6.3425,69
> 2013/05/08 08:02:07,6.3425,6.34,6.3425,6.34,74
> 2013/05/08 08:02:07,6.3425,6.34,6.34,6.3425,80
> 2013/05/08 08:02:07,6.345,6.3425,6.3425,6.345,87
> 2013/05/08 08:02:13,6.345,6.3425,6.345,6.3425,110
>
> Goal; an xts object something like this
> (however the microseconds may appear):
>
>                                           High,Low,Open,Close,Vol
> 2013-05-08 08:02:04.000,6.35,6.345,6.35,6.345,172
> 2013-05-08 08:02:07.001,6.345,6.3425,6.345,6.3425,69
> 2013-05-08 08:02:07.002,6.3425,6.34,6.3425,6.34,74
> 2013-05-08 08:02:07.003,6.3425,6.34,6.34,6.3425,80
> 2013-05-08 08:02:07.004,6.345,6.3425,6.3425,6.345,87
> 2013-05-08 08:02:13.000,6.345,6.3425,6.345,6.3425,110
>
> Any help greatly appreciated. Thanks.
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/convert-ordered-but-non-unique-csv-to-unique-xts-tp4666712.html
> Sent from the Rmetrics mailing list archive at Nabble.com.
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list