[R] POSIXlt class and lapply
William Dunlap
wdun|@p @end|ng |rom t|bco@com
Thu Feb 14 21:03:55 CET 2019
Somewhere between R-3.3.3 and R-3.5.2 a POSIXlt method for as.list() was
added, and lapply probably calls as.list().
> RCompare(methods("as.list"))
R version 3.3.3 (2017-03-06) | R version 3.5.1
(2018-07-02)
[1] as.list.data.frame as.list.Date | [1]
as.list.data.frame as.list.Date
[3] as.list.default as.list.environment | [3] as.list.default
as.list.environment
[5] as.list.factor as.list.function | [5] as.list.factor
as.list.function
[7] as.list.numeric_version as.list.POSIXct | [7]
as.list.numeric_version as.list.POSIXct
see '?methods' for accessing help and source code | [9] as.list.POSIXlt
| see '?methods' for
accessing help and source code
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Thu, Feb 14, 2019 at 9:45 AM Newell, Paul <paul.newell using metoffice.gov.uk>
wrote:
> 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
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]
More information about the R-help
mailing list