[R] Beginner's question: number formatting
figurski at mail.med.upenn.edu
Fri Oct 17 19:55:18 CEST 2008
I have a problem with formatting a single number to show leading zeros.
For example, I want "2" displayed as "002".
My numbers have 1 to 3 digits and I would like them all to display 3
digits for printing. I know I could use "paste" in a loop with several
"if"s, but I was wondering if there is a single function that can do this.
I have tried "format", "prettyNum" and "formatC" back and forth, but
these functions don't seem to be able to display leading zeros. Please help.
Michal J. Figurski
More information about the R-help