[R] POSIXlt class and lapply

Newell, Paul p@u|@newe|| @end|ng |rom meto|||ce@gov@uk
Thu Feb 14 16:28:50 CET 2019


Dear R-helpers,

We have recently upgraded from R-3.3.1 to R-3.5.2.

It seems there has been a change in behaviour of `lapply` and the `POSIXlt` class that I cannot find explicitly documented.


In R-3.3.1:

> lapply(as.POSIXlt(Sys.Date()), length)
$sec
[1] 1
$min
[1] 1
$hour
[1] 1
$mday
[1] 1
$mon
[1] 1
$year
[1] 1
$wday
[1] 1
$yday
[1] 1
$isdst
[1] 1


whereas, in R-3.5.2:

> lapply(as.POSIXlt(Sys.Date()), length)
[[1]]
[1] 1


Is this change in behaviour intentional?

Realistically, I cannot see anything documented to say that `lapply` should behave as per R-3.3.1 on a `POSIXlt` object, so it is/was perhaps unwise to rely on it.


Best wishes,
Paul Newell


More information about the R-help mailing list