índice de tiempo de visualización en xts R
Pregunta
Quiero analizar csv con índice temporizada micro-segundos. Por lo tanto, escribí código como el siguiente:
t<-read.zoo("test", index.column = 1, sep=",",header=TRUE, format="%Y-%m-%d %H:%M:%OS")
t.xts<-as.xts(t)
después de entonces, he tratado de mostrar esto, pero no pude ver la información de tiempo en el índice.
> t.xts[1:10,4]
drate
2010-09-28 " -149"
2010-09-28 " -269"
2010-09-28 " -358"
2010-09-28 " -358"
2010-09-28 " -239"
2010-09-28 " -149"
2010-09-28 " -149"
2010-09-28 " -149"
2010-09-28 " -119"
2010-09-28 " -149"
Me trató opciones (digits.secs = 6), pero no funcionó.
Solución
Sería de gran ayuda si usted podría ofrecer algunas líneas de su archivo CSV. Configuración options(digits.secs=6)
funciona para mí. También podría intentar establecer el formato con indexFormat
manualmente.
> x <- .xts(1:5, 1:5+runif(5))
> x
[,1]
1969-12-31 18:00:01 1
1969-12-31 18:00:02 2
1969-12-31 18:00:03 3
1969-12-31 18:00:04 4
1969-12-31 18:00:05 5
> indexFormat(x) <- "%Y-%m-%d %H:%M:%OS3"
> x
[,1]
1969-12-31 18:00:01.915 1
1969-12-31 18:00:02.002 2
1969-12-31 18:00:03.134 3
1969-12-31 18:00:04.981 4
1969-12-31 18:00:05.204 5
> indexFormat(x) <- "%Y-%m-%d %H:%M:%OS"
> options(digits.secs=6)
> x
[,1]
1969-12-31 18:00:01.914681 1
1969-12-31 18:00:02.001752 2
1969-12-31 18:00:03.134311 3
1969-12-31 18:00:04.981147 4
1969-12-31 18:00:05.204021 5
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow