Message-ID: <710BDF90-B13A-47CE-980B-9276293C7E45@llnl.gov>
Date: 2018-06-08T21:12:17Z
From: MacQueen, Don
Subject: Date class shows Inf as NA; this confuses the use of is.na()
In-Reply-To: <CAGg4omXVJj3vnK1+Z4zaHeuQ5Q+GjsOcvY22D13-okpjzWCsuA@mail.gmail.com>
> as_date
Error: object 'as_date' not found
Must be from some not-named package...
But don't confuse the format of an object when printed with its underlying value:
> as.Date(Inf,origin = '1970-01-01')
[1] NA
> str(as.Date(Inf,origin = '1970-01-01'))
Date[1:1], format: NA
> as.numeric(as.Date(Inf,origin = '1970-01-01'))
[1] Inf
> is.na(Inf)
[1] FALSE
> is.na(as.Date(Inf,origin = '1970-01-01'))
[1] FALSE
> str(as.Date(27,origin = '1970-01-01'))
Date[1:1], format: "1970-01-28"
> as.numeric(as.Date(27,origin = '1970-01-01'))
[1] 27
--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
?On 6/8/18, 1:02 PM, "R-devel on behalf of Werner Grundlingh" <r-devel-bounces at r-project.org on behalf of wgrundlingh at gmail.com> wrote:
In the following example, the date class shows Inf as NA
> as_date(Inf, origin = '1970-01-01')
[1] NA
This is misleading as is.na() reports incorrectly
> is.na(as_date(Inf, origin = '1970-01-01'))
[1] FALSE
The correct approach here would probably to have an Inf (and -Inf)
*displayed* rather than NA.
[[alternative HTML version deleted]]
______________________________________________
R-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel