Skip to content

NaN/NA and sprintf double format (PR#1561)

1 message · Jonathan Rougier

#
ripley@stats.ox.ac.uk wrote:
Naturally it's a feature!  But I agree that an extra sentance or two on
the help page would be a good idea.  I suggest appending the following
as a new paragraph to the Value section:

As \code{sprintf} is simply a wrapper for the C function of the same
name, it is the user's responsibility to ensure that the objects passed
in \code{\dots} correspond to the format.  Otherwise the resulting
string may contain garbage.  For example, the typical R numeric object
is a float not an integer (see Examples, below).  Likewise, C does not
recognise special values like \code{NA}, so \code{sprintf("Our survey
said: %f", NA)} is not going to work as you might want.

I've cc'ed this to r-bugs.  Jonathan.