[R] Paddding an integer with zeros
culpritNr1
ig2ar-saf1 at yahoo.co.uk
Tue Oct 21 19:40:59 CEST 2008
sprintf works like a charm.
I feel rather embarrassed right now. I see that when I do ?format, at the
very end of the documentation, sprintf is suggested as further reading.
muito obrigado
culpritNr1
Henrique Dallazuanna wrote:
>
> Try this:
>
> formatC(12, width = 5, flag = "0")
> or
> sprintf("%05d", 12)
>
> On Tue, Oct 21, 2008 at 3:24 PM, culpritNr1 <ig2ar-saf1 at yahoo.co.uk>
> wrote:
>
>>
>> Hello List,
>>
>> Can anybody point me to a number-to-string formatting function?
>>
>> I need to convert, say, 12 to 00012.
>>
>> I tried format() but its too stubborn: it seems to only pad with spaces.
>>
>> Thank you,
>>
>> Your culpritNr1
>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Paddding-an-integer-with-zeros-tp20095300p20095300.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> 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.
>>
>
>
>
> --
> Henrique Dallazuanna
> Curitiba-Paraná-Brasil
> 25° 25' 40" S 49° 16' 22" O
>
> [[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.
>
>
--
View this message in context: http://www.nabble.com/Paddding-an-integer-with-zeros-tp20095300p20095582.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list