[Rd] Flag '#' in sprintf() gives an error in R v2.9.0 devel
hb at stat.berkeley.edu
Mon Feb 2 20:34:37 CET 2009
in R v2.8.1 patched (2008-12-22 r47296) the following works:
> sprintf("%#x", 1)
whereas in R v2.9.0 devel (2009-01-08 r47515) it gives:
> sprintf("%#x", 1);
Error in sprintf("%#x", 1) :
use format %f, %e, %g or %a for numeric objects
Not sure if this was an intended move or not.
Typically, the '#' flag modifies the output of (s)printf() as follows:
"# Used with o, x or X specifiers the value is preceeded with 0, 0x
or 0X respectively for values different than zero.
Used with e, E and f, it forces the written output to contain a
decimal point even if no digits would follow. By default, if no digits
follow, no decimal point is written. Used with g or G the result is
the same as with e or E but trailing zeros are not removed."
I know there are many flavors of what format strings printf() supports
and I don't have the Kernighan & Ritchie book in help(sprintf).
More information about the R-devel