Simple percentage formatting in R

While collecting some corpus statistics, I came across a handy function in R that formats decimal into percentage expressions:

The function is clearly most valuable if all values are in a range of 1 to 100 percent, as the documentation also suggests: “Multiply by one hundred and display percent sign.” [1] In contrast, the sprintf equivalent may be ‘configured’ such as to show more decimal places.

On Ubuntu, the enclosing package can be installed via

 References

  • [1] scales package documentation

Edits

  • 2017-05-03: Use library(scales) instead of library(ggplot2). Thanks to Vital!

2 comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box