문제

I want to create a time series from a start date&time (t1) to a finish date&time (t2) by 10 minute intervals.

the code below works fine for all other t2 times bar 23:50:00

library(chron)
t1 <- chron("1/1/2006", "00:00:00")
t2 <- chron("1/3/2006", "23:50:00")
deltat <- times("00:10:00")
tt <- seq(t1, t2, by = times("00:10:00"))

I have tried this code in Rstudio on both linux and windows platforms, as well as from terminal on linux, to no avail.

any thoughts would be appreciated.

도움이 되었습니까?

해결책

You have a floating point issue. To get around it, you could add an additional second to t2

t2 = chron("1/3/2006", "23:50:01")
seq(t1, t2, by = times("00:10:00"))

Search for floating point on stack overflow. In R, the classic example is

R> sqrt(2)^2 ==2
[1] FALSE
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top