[R-SIG-Finance] XTS with unique time stamps?

Brian G. Peterson brian at braverock.com
Mon Jan 31 13:05:16 CET 2011

On Monday, January 31, 2011 12:55:03 am Worik wrote:
> I am having trouble with non-unique time stamps in an xts.
> My underlying data has some repeated rows (in a csv file).
> How can I easily get rid of the duplicates?
> I feel I must be missing something simple.  If not I can concoct an
> example to illustrate my problem.


It depends on what you need.

If you can remove the rows with duplicated indices, then a construction such 


should work.

If you need all of the observations, and need to artificially make them unique 
(as is a common problem with tick data), then you will see discussion in the 
list archives here and other places regarding adding artificial indices to high 
frequency data while preserving order. You will need the latest xts from R-
Forge and use a construction like this:


which will (by default) add .00001 sec to each non-unique index after the 
first, preserving order, and providing every observation with a unique index.  
Note that this presumes that the original order of the observations was 
correct in the first place, no provision has been made if you have different 

Thanks to Jeff Ryan for (very) recently adding this second method.


  - Brian

Brian G. Peterson
Ph: 773-459-4973
IM: bgpbraverock

More information about the R-SIG-Finance mailing list