View source: R/makePercentage.R
makePercentage | R Documentation |
Takes an object x
of class "character" or "numeric". Returns an
object of class "character" in which the number is expressed as a
percentage.
makePercentage(x, dp = 0)
x |
Object of class "character," "integer," or "numeric." |
dp |
Integer specifying the number of decimal places in the returned string. |
By default, the returned string will have no decimal digits: it will be
"57%", not "57.0%". But if dp
is greater than 0, the returned
string will always have dp
decimal places.
A string, e.g., "57%".
makePercentage(.5) # "50%" makePercentage(.555) # "56%" makePercentage(.555, dp = 4) # "55.5000%" makePercentage(5) # "500%" makePercentage(5, dp = 2) # "500.00%" makePercentage(1:3) # "100%" "200%" "300%"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.