[Rd] as.character.Date() strips names in R 4.3.2 beta, bug?
Martin Maechler
m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Tue Oct 24 10:53:10 CEST 2023
>>>>> Andrew Piskorski
>>>>> on Tue, 24 Oct 2023 00:01:58 -0400 writes:
> In previous versions of R,
Not in R 4.3.0 or 4.3.1 {you are a bit late with updating ..}.
> as.character.Date() retained any names on
> its input vector. In R 4.3.2 beta, it removes names. Is this change
> intentional, or a bug? (For what it's worth, I greatly dislike this
> change, and hope it gets changed back.)
Yes, this change has been *very* intentional: as.character() for
these objects since 4.3.0 (April 2023) finally behaves as other
as.character() methods and *does* drop attributes.
The NEWS entry
(visible since more than a year if you'd follows NEWS.Rd tweats/.. etc)
is
• ‘as.character(<POSIXt>)’ now behaves more in line with the
methods for atomic vectors such as numbers, and is no longer
influenced by ‘options()’. Ditto for
‘as.character(<Date>)’. The ‘as.character()’ method gets
arguments ‘digits’ and ‘OutDec’ with defaults _not_
depending on ‘options()’. Use of ‘as.character(*, format = .)’
now warns.
At the time (Sep 2022!) there was quite some traffic on R-devel
about this, IIRC.
Often it's most convenient for people to use format() instead
of as.character() if they want to keep names, notably here,
because before the fix, the as.character() method for Date and POSIXt
*was* identical to format() --- contrary to all other methods
for "simple" vectors.
There's more about this if just simply at ?as.character.Date
Best regards,
Martin
--
Martin Maechler
ETH Zurich and R Core team
More information about the R-devel
mailing list