From michaelchirico4 at gmail.com  Fri May 19 17:23:12 2017
From: michaelchirico4 at gmail.com (Michael Chirico)
Date: Fri, 19 May 2017 11:23:12 -0400
Subject: [Rd] Inconsistency in handling of numeric input with %d by sprintf
Message-ID: <CAPRVBcx3OjFK0G=hk1g8qChYiQ7cuZPpep-kju-_BD4MErhDuA@mail.gmail.com>

Consider

#as.numeric for emphasis
sprintf('%d', as.numeric(1))
# [1] "1"

vs.

sprintf('%d', NA_real_)

>  Error in sprintf("%d", NA_real_) :

   invalid format '%d'; use format %f, %e, %g or %a for numeric object
>

I understand the error is correct, but if it works for other numeric input,
why doesn't R just coerce NA_real_ to NA_integer_?

Michael Chirico

	[[alternative HTML version deleted]]



[Rd] Inconsistency in handling of numeric input with %d by sprintf
Michael Chirico