[R] Date as numeric

MacQueen, Don macqueen1 at llnl.gov
Mon Mar 23 16:20:40 CET 2015

No formula behind that:

> as.numeric("2012-11-11 19:05:00 UTC")
[1] NA
Warning message:
NAs introduced by coercion

If a character string is recognizable as a number, you get that number.
For example:

> as.numeric('3')
[1] 3

But your character string isn't recognizable as a number, so you get NA,
meaning a missing value. For another example:
> as.numeric( c('3','a','4') )
[1]  3 NA  4
Warning message:

NAs introduced by coercion

> as.numeric(as.POSIXct("2012-11-11 19:05:00 UTC"))
[1] 1352689500
 > ?DateTimeClasses

for more information.


Don MacQueen

Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550

On 3/23/15, 7:51 AM, "Eduardo M. A. M.Mendes" <emammendes at gmail.com> wrote:

>I wonder what the formula behind as.numeric("2012-11-11 19:05:00 UTC²) is.
>Many thanks
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list