[R] strange Sys.Date() side effect

MacQueen, Don macqueen1 at llnl.gov
Thu Jan 12 23:26:30 CET 2012


My best guess is that you are misunderstanding what the c() function does.
I'd suggest reading the help page for c, obtained by typing
  ?c
Note that if you supply c() with objects of different types (as you have),
the results will probably not be what you wanted.

Given what c() does, your output and warning message make sense. But I'm
unable to figure out what you're really trying to do. Something like this,
perhaps?

> N <- 2; sprintf('N = %d', N)
[1] "N = 2"


-Don


-- 
Don MacQueen

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





On 1/10/12 5:04 AM, "Czerminski, Ryszard"
<Ryszard.Czerminski at astrazeneca.com> wrote:

>Any ideas what is the problem with this code?
>
>> N <- 2; c(Sys.Date(), sprintf('N = %d', N))
>[1] "2012-01-10" NA
>Warning message:
>In as.POSIXlt.Date(x) : NAs introduced by coercion
>
>Best regards,
>Ryszard
>
>Ryszard Czerminski
>AstraZeneca Pharmaceuticals LP
>35 Gatehouse Drive
>Waltham, MA 02451
>USA
>781-839-4304
>ryszard.czerminski at astrazeneca.com
>
>
>--------------------------------------------------------------------------
>Confidentiality Notice: This message is private and may ...{{dropped:11}}
>
>______________________________________________
>R-help at r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide
>http://www.R-project.org/posting-guide.html
>and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list