Skip to content
Prev 139025 / 398506 Next

format numbers into percentages

On Sun, Mar 9, 2008 at 3:36 PM, tom soyer <tom.soyer at gmail.com> wrote:
My favorite is sprintf(), which allow you to control number of digits
at the same time you control for width etc, e.g.:

  x <- seq(from=0, to=1, by=0.05)
  s1 <- sprintf("%.2f%%", 100*x)
  s2 <- sprintf("%6.2f%%", 100*x)

/H