Skip to content

c(ITime) and seq( ITime ) lose ITime attribute and coerce to integer #3628

@UweBlock

Description

@UweBlock
t1 <- seq(from = as.ITime("0:00"), to = as.ITime("0:40"), by = as.ITime("0:06"))
str(t1)
# int [1:7] 0 360 720 1080 1440 1800 2160

# workaround:
t2 <- as.ITime(seq(from = as.ITime("0:00"), to = as.ITime("0:40"), by = as.ITime("0:06")))
str(t2)
# 'ITime' int [1:7] 00:00:00 00:06:00 00:12:00 00:18:00 00:24:00 00:30:00 00:36:00

Ran into it while answering https://stackoverflow.com/a/56454903/3817004

Related issue: unique( ITime ) loses ITime attribute and coerces to integer ?

Just recognized that the same happens with c():

c(as.ITime("0:00"), as.ITime("1:00:00"))
# [1]    0 3600

Output of sessionInfo():

R version 3.6.0 (2019-04-26)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)

Matrix products: default

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

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

other attached packages:
[1] magrittr_1.5      data.table_1.12.3

loaded via a namespace (and not attached):
[1] compiler_3.6.0  hms_0.4.2       tools_3.6.0     pkgconfig_2.0.2 rlang_0.3.4  

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions