Skip to content

add zero in front of numbers

4 messages · Yan Jiao, Luis Ridao, January Weiner +1 more

#
Dear Yan,

apart from formatC, you can also use sprintf, which works almost
exactly like the C sprintf function. To convert an integer x to a
string with 5 leading 0s, you do:

sprintf( "%05d", x )

Best regards,

j.
On Mon, Apr 4, 2011 at 12:35 PM, Yan Jiao <y.jiao at ucl.ac.uk> wrote:

  
    
#
On 04.04.2011 12:35, Yan Jiao wrote:
formatC(c(1, 19), flag=0, width=3)

Uwe Ligges