[R] format integer numbers with leading 0

Lasse Kliemann lasse at lassekliemann.de
Thu Jan 4 21:34:02 CET 2018


Marc Girondot via R-help <r-help at r-project.org> writes:

> I would like format integer number as characters with leading 0 for a 
> fixed width, for example:
>
> 1 shoud be "01"
> 2 shoud be "02"
> 20 should be "20"

formatC(x, width=2, flag="0")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20180104/4e503279/attachment.sig>


More information about the R-help mailing list