[R] add zero in front of numbers

Uwe Ligges ligges at statistik.tu-dortmund.de
Mon Apr 4 18:12:16 CEST 2011



On 04.04.2011 12:35, Yan Jiao wrote:
> Dear R users,
>
> I need to add 0 in front of a series of numbers, e.g. 1->001, 19->019,
> Is there a fast way of doing that?

formatC(c(1, 19), flag=0, width=3)

Uwe Ligges

> Many thanks
>
> yan
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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