Skip to content
Prev 61146 / 63424 Next

as.Date without "origin"

Dear all,

I would throw in my vote to have origin = "1970-01-01" as a default in as.Date().  Why?  Well, in fact, the "converse" function as.numeric() does have an implicit default:
[1] 19298

In fact, as.numeric seems to not even have a method for class "Date", and so as.numeric() does not even have an argument "origin" or the like.

In any case, when using Date objects, it may happen that the result is of clas numeric. For example:
[1] 19298

So, in order to transform the result back to class "Date" using as.Date(), I always need to remember the universal default origin 1970-01-01 and I need to write it out explicitly.

I find that rather inconvenient, and so having the default origin as a default would make very much sense to me here.

Of course, for that particular example, it would also help me if ifelse() would properly handle Date vectors.

Best
Johannes
Message-ID: <trinity-944275fc-476b-4c4d-b8db-bbf3ef907154-1667422061742@3c-app-webde-bap25>
In-Reply-To: <UVIu3zmRKG3oM__PzasW3vvKTYxIrBpYeoHDaghpllF9-_HuAAPEmQbDweRrMj3_KrKDjbmOI5EySuBKOt_0vQsOJRLcmO7w20rqi5MSo6I=@protonmail.com>