2008/9/15 Oliver Bandel <
[hidden email]>:
>> sprintf("%03s", as.character(1:5))
> [1] " 1" " 2" " 3" " 4" " 5"
>>
> =================================================================
>
> There should be a leading "0" isntead of space-chars?!
>
In R, sprintf is a wrapper for the C printf functions, and if you
read the C man page it says this about the 0 prefix:
0
The value should be zero padded. For d, i, o, u, x, X, a, A, e, E, f,
F, g, and G conversions, the converted value is padded on the left
with zeros rather than blanks. If the 0 and - flags both appear, the 0
flag is ignored. For other conversions, the behavior is undefined.
Interestingly R seems to pad with spaces (like yours), but my cygwin C
version pads with zeroes. Such is the nature of undefined behaviour!
Barry
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide
http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.