[R] lubridate inserting unwelcome 9:21

Troels Ring tring at gvdnet.dk
Tue Mar 28 17:28:30 CEST 2017


Dear friends - I have a series of times on successive days and would 
like to convert them into a successive common time for each person (ID) 
. Using lubridate and adding days(1) does as expected apart from 
changing time zone to LMT from UTC and suddenly adding 9:21 (H:M) to all 
times. Individual parts of the instructions seem OK. I'm sorry for the 
clumsy demonstration - but the error comes through.

R version 3.3.2 (2016-10-31) - Windows.

All best wishes
Troels

library(lubridate)

SSS <- structure(list(ID = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L,
3L, 3L, 3L, 3L, 3L, 3L), Time = c(-1L, 0L, 1L, 2L, 3L, 4L, 5L,
6L, 7L, 8L, 9L, 10L, 11L, -1L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L,
8L, 9L, 10L, -1L, 0L, 1L, 2L, 3L, 4L, 5L), VT = structure(c(3L,
5L, 11L, 11L, 8L, 10L, 8L, 10L, 8L, 7L, 11L, 5L, 5L, 12L, 5L,
7L, 7L, 5L, 5L, 8L, 10L, 8L, 7L, 7L, 7L, 2L, 8L, 7L, 8L, 7L,
10L, 8L), .Label = c("02:00", "03:00", "04:00", "05:00", "06:00",
"09:00", "10:00", "11:00", "11:30", "12:00", "13:00", "14:00",
"15:00", "17:00", "18:00", "21:30", "23:00"), class = "factor")), .Names 
= c("ID",
"Time", "VT"), row.names = c(NA, 32L), class = "data.frame")

SSS$VT  <- parse_date_time(SSS$VT,"HM")
str(SSS$VT)

TT <- list()
for(i in 1:3) {
#i <- 1
BS <- subset(SSS,ID==i)
TT[[i]] <- c(BS$VT + (1:length(BS[,1])-1)*days(1))
}
BS$VT
(1:length(BS[,1])-1)*days(1)

#these appear as expected but

TT

#appears disturbed 9:21 inserted - LMT time zone - how comes?



More information about the R-help mailing list