Description Usage Arguments Value Examples
Converts a numeric vector into a vector of relative percentages.
1 2 3 4 5 | fv_percent(x, digits = getOption("numformdigits"), ...)
ffv_percent(...)
ffv_percent(...)
|
x |
A numeric vector. |
digits |
The number of digits to use. Defaults to 1. Can be set
globally via: |
... |
Other arguments passed to |
Returns a string of publication ready relative percentages.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | fv_percent(1:4)
fv_percent(sample(1:100, 20))
## Not run:
library(tidyverse)
mtcars %>%
count(cyl, gear) %>%
group_by(cyl) %>%
mutate(perc = fv_percent(n, digits = 0))
mtcars %>%
count(cyl, gear) %>%
group_by(cyl) %>%
mutate(perc = fv_percent(n, digits = 0)) %>%
ggplot(aes(gear, n)) +
geom_bar(stat = 'identity') +
facet_wrap(~cyl, ncol = 1) +
geom_text(aes(y = n + 1, label = perc))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.