[R] Date Time, as.POSIXct used locale, strange plot behavior

Tilmann Faul T||m@nn_F@u| @end|ng |rom t-on||ne@de
Thu Apr 29 21:22:44 CEST 2021


Hy,

stumbled over the following problem while plotting DateTime Objects.

plot(as.POSIXct(c("2021-04-21 00:00:00", "2021-04-21 23:59:59")), c(0,
1), type='l')

arrows(as.POSIXct("2021-04-21 00:00:00", tz="CEST"),
       0.3,
       as.POSIXct("2021-04-21 00:00:00", tz="CEST"),
       0.2,
       length=0.07, angle=15)

# arrow at 02:00, why?

arrows(as.POSIXct("2021-04-21 00:00:00"),
       0.3,
       as.POSIXct("2021-04-21 00:00:00"),
       0.2,
       length=0.07, angle=15, col='red')

# arrow at 00:00 as expected

as.POSIXct(c("2021-04-21 00:00:00", "2021-04-21 23:59:59"))[1]
# [1] "2021-04-21 CEST"
as.POSIXct("2021-04-21 00:00:00", tz="CEST")
# [1] "2021-04-21 CEST"
as.POSIXct("2021-04-21 00:00:00")
# [1] "2021-04-21 CEST"

all representations on my system are the same, why is the plot location
of the arrows different??
I am located in Germany, my locale:
Sys.getlocale()
[1]
"LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8;LC_COLLATE=de_DE.UTF-8;LC_MONETARY=de_DE.UTF-8;LC_MESSAGES=de_DE.UTF-8;LC_PAPER=de_DE.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_DE.UTF-8;LC_IDENTIFICATION=C"

Any Idea?

Best regards
Tilmann



More information about the R-help mailing list