Skip to content
Prev 7415 / 15274 Next

XTS with unique time stamps?

On Monday, January 31, 2011 12:55:03 am Worik wrote:
Worik,

It depends on what you need.

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

myxts<-myxts[!duplicated(index(myxts))]

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:

myxts<-make.unique.index(myxts)

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 
circumstances.

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

Regards,

  - Brian