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

Adaikalavan Ramasamy a.ramasamy at imperial.ac.uk
Mon Sep 15 23:55:56 CEST 2008


Try

   sprintf("%03.0f", 1:5)

   formatC(1:5, width=3, flag="0")

Regards, Adai



Oliver Bandel wrote:
> Hello,
>
>
> please look here:
>
>
>
>
>
> =================================================================
>> sprintf("%03s", as.character(1:5))
> [1] "  1" "  2" "  3" "  4" "  5"
> =================================================================
>
> There should be a leading "0" isntead of space-chars?!
>
>
>
> I use  R version 2.6.2 (2008-02-08)
>
>
> Ciao,
>   Oliver
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list