0

I have a csv with this kind of data for a specific date that I read with read.csv

160525.000,38.63
160526.086,38.63
160526.604,38.62
160526.710,38.63
160526.343,38.62

date = "20150824"

I transform the first column to datetime with:

idx=strptime(paste(date,Data[,1]),"%Y%m%d %H%M%OS")

to get

"2015-08-24 16:05:25.000 GMT" "2015-08-24 16:05:26.086 GMT" 
"2015-08-24 16:05:26.604 GMT" "2015-08-24 16:05:26.710 GMT"
"2015-08-24 16:05:27.343 GMT"

I construct the xts object with:

data=as.xts(Data[,-1],order.by=idx)

to get data

> head(data)
                       V2
2015-08-24 16:05:25.000 38.63
2015-08-24 16:05:26.085 38.63
2015-08-24 16:05:26.604 38.62
2015-08-24 16:05:26.710 38.63
2015-08-24 16:05:27.342 38.62

You will notice that the time index of the xts object is false for some rows (2,5). I failed to find why?

here is the info on my R session

> sessionInfo()
R version 3.2.0 (2015-04-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United     Kingdom.1252    LC_MONETARY=English_United Kingdom.1252
[4] LC_NUMERIC=C                            LC_TIME=English_United Kingdom.1252    

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] highfrequency_0.4-1           PerformanceAnalytics_1.4.3662  plsgenomics_1.3-1             boot_1.3-16                  
[5] MASS_7.3-40                   quantmod_0.4-5                TTR_0.23-0                    xts_0.9-7                    
[9] zoo_1.7-12                   

loaded via a namespace (and not attached):
[1] timeSeries_3012.100 tools_3.2.0         blotter_0.9.1666    grid_3.2.0          timeDate_3012.100   quantstrat_0.9.1687
[7] lattice_0.20-31  

Does anyone know how this could happen? And more importantly how to solve it? ;)

Thanks in advance

Anass
  • 73
  • 4
  • Remember that how an object _prints_ is not what it is. There's nothing wrong with your data. It just prints weird. – Joshua Ulrich Sep 29 '15 at 00:10
  • Thx @JoshuaUlrich. I searched for hours but I still missed this answer on SO. Thanks again for clarifyinf this issue. – Anass Sep 29 '15 at 08:35

0 Answers0