Skip to content

format numbers into percentages

3 messages · tom soyer, Henrik Bengtsson, Henrique Dallazuanna

#
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
#
Perhaps:

sprintf("%g%%", x*100)
On 09/03/2008, tom soyer <tom.soyer at gmail.com> wrote: