[R] POSIXct-coerced NA's not considered NA by is.na()

Alexander Shenkin ashenkin at ufl.edu
Fri Aug 24 15:47:41 CEST 2012


Hello folks,

I found a strangeness while experimenting with POSIXct vectors and
lists.  It seems that coerced NA's aren't "real" NAs, at least as
considered by is.na()?

> date_vec = c(as.POSIXct(now()), as.POSIXct(now()+1),NA,"b")
> date_vec
[1] "2012-08-22 15:00:46 COT" "2012-08-22 15:00:47 COT" NA

[4] NA
Warning message:
In as.POSIXlt.POSIXct(x, tz) : NAs introduced by coercion
> date_vec[4]
[1] NA
Warning message:
In as.POSIXlt.POSIXct(x, tz) : NAs introduced by coercion
> is.na(date_vec[4])
[1] FALSE
> is.na(date_vec[3])
[1] TRUE
> is.POSIXct(date_vec[4])
[1] TRUE



More information about the R-help mailing list