On 08/02/2024 7:58 p.m., Jiří Moravec wrote:
> This is a workaround, and could be the basis for a round.Date
improvement:
> date <- Sys.Date()
> as.Date(round(as.POSIXct(date), "years"))
> as.Date(round(as.POSIXct(Sys.Date() + 180), "years"))
> Duncan Murdoch
That would work, per
> This is a workaround, and could be the basis for a round.Date
improvement:
> date <- Sys.Date()
> as.Date(round(as.POSIXct(date), "years"))
> as.Date(round(as.POSIXct(Sys.Date() + 180), "years"))
> Duncan Murdoch
That would work, perhaps structured similarly as `trunc.Date` is.
The only
Apologies then. I was using R version 4.1.2 (Bird Hippie) and looks like
someone implemented a better trunc.Date version in the meantime.
# v4.1.2
> trunc.Date
function (x, ...)
round(x - 0.499)
# Unstable (2024-02-07 r85873)
> trunc.Date
function (x, units = c("secs", "mins", "hours", "d
This is a workaround, and could be the basis for a round.Date improvement:
date <- Sys.Date()
as.Date(round(as.POSIXct(date), "years"))
as.Date(round(as.POSIXct(Sys.Date() + 180), "years"))
Duncan Murdoch
On 08/02/2024 12:23 p.m., Henrik Bengtsson wrote:
Technically, there is a round()
Technically, there is a round() for 'Date' objects, but it doesn't
seem very useful, because it basically just fall back to the default
round() method, which only takes the 'digits' argument.
Here's an example:
> date <- Sys.Date()
> class(date)
[1] "Date"
We see that there are only two round()
Às 14:36 de 08/02/2024, Olivier Benz via R-devel escreveu:
On 8 Feb 2024, at 15:15, Martin Maechler wrote:
Jiří Moravec
on Wed, 7 Feb 2024 10:23:15 +1300 writes:
This is my first time working with dates, so if the answer is "Duh, work
with POSIXt", please ignore it.
Why is not `round
I just wanted to add some additional problems from trying to replicate this.
`trunc` does indeed work as advertised here, as does calling
`round.POSIXt(Sys.Date())`
and `round(Sys.Date())`. These functions are definitely implemented.
However, I am also able to replicate Jiří’s error:
```
> round
> On 8 Feb 2024, at 15:15, Martin Maechler wrote:
>
>> Jiří Moravec
>>on Wed, 7 Feb 2024 10:23:15 +1300 writes:
>
>> This is my first time working with dates, so if the answer is "Duh, work
>> with POSIXt", please ignore it.
>
>> Why is not `round.Date` and `trunc.Date` "implement
> Jiří Moravec
> on Wed, 7 Feb 2024 10:23:15 +1300 writes:
> This is my first time working with dates, so if the answer is "Duh, work
> with POSIXt", please ignore it.
> Why is not `round.Date` and `trunc.Date` "implemented" for `Date`?
> Is this because `Date` is (
This is my first time working with dates, so if the answer is "Duh, work
with POSIXt", please ignore it.
Why is not `round.Date` and `trunc.Date` "implemented" for `Date`?
Is this because `Date` is (mostly) a virtual class setup for a better
inheritance or is that something that is just missin
10 matches
Mail list logo