[R] sprintf does not fill with "0"?!

Earl F. Glynn efg at stowers-institute.org
Mon Sep 15 23:44:33 CEST 2008


"Oliver Bandel" <oliver at first.in-berlin.de> wrote in message 
news:1221513552.6194.5.camel at calcman...
> Hello,
>> sprintf("%03s", as.character(1:5))
> [1] "  1" "  2" "  3" "  4" "  5"

Would this be OK as an alternative?

> sprintf("%3.3d", 1:5)
[1] "001" "002" "003" "004" "005"

efg

Earl F. Glynn
Scientific Programmer
Stowers Institute for Medical Research



More information about the R-help mailing list