Description Usage Arguments Value See Also Examples
f_percent
- A wrapper for f_num
that formats
percent values as labeled percentages.
f_prop2percent
- A wrapper for f_num
that formats
proportions as labeled percentages.
f_pp
- A wrapper for f_prop2percent
that requires
less typing and has digits
set to 0
by default.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
x |
A vector of proportions. |
digits |
The number of digits to use. Defaults to 1. Can be set
globally via: |
less.than.replace |
logical. If |
s |
A string to paste at the end of the output from |
... |
Other values passed to |
Returns a string of publication ready digits.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | f_percent(c(30, 33.45, .1))
f_percent(c(30, 33.45, .1), 1)
f_percent(c(0.0, 0, .2, -00.02, 1.122222, pi))
f_prop2percent(c(.30, 1, 1.01, .33, .222, .01))
f_pp(c(.30, 1, 1.01, .33, .222, .01))
f_percent(c(30, 33.45, .1), digits = 0, less.than.replace = TRUE)
## Escaped for LaTeX:
f_percent(c(30, 33.45, .1), digits = 0, less.than.replace = TRUE, s = '\\%')
f_prop2percent(c(.30, 1, 1.01, .33, .222, .01, .0001, NA), digits = 0,
less.than.replace = TRUE)
## Not run:
library(tidyverse)
mtcars %>%
count(cyl, gear) %>%
group_by(cyl) %>%
mutate(prop = n/sum(n)) %>%
ggplot(aes(gear, prop)) +
geom_bar(stat = 'identity') +
facet_wrap(~cyl, ncol = 1) +
scale_y_continuous(labels = ff_prop2percent(digits = 0))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.