[Rd] Inconsistency in handling of numeric input with %d by sprintf
Michael Chirico
michaelchirico4 at gmail.com
Fri May 19 17:23:12 CEST 2017
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]]
More information about the R-devel
mailing list