scale_continuous | R Documentation |
Wrappers around 'ggplot2::scale_x_continuous' and 'ggplot2::scale_y_continuous' to make it easy to format percentages.
scale_x_pct(..., limits = c(0, 1), labels = scales::percent)
scale_y_pct(..., limits = c(0, 1), labels = scales::percent)
... |
Arguments to 'ggplot2::scale_x_continuous' and 'ggplot2::scale_x_continuous' |
limits |
default is 'c(0, 1)' See '?ggplot2::scale_x_continuous' for additional details |
labels |
default is 'scales::percent' See '?ggplot2::scale_x_continuous' for additional details |
https://github.com/thomas-neitmann/scalesextra
library(dplyr)
library(ggplot2)
library(palmerpenguins)
penguins %>%
dplyr::count(species) %>%
mutate(pct = n / sum(n)) %>%
ggplot(data = .,
aes(x = species,
y = pct)) +
geom_bar(stat = "identity")
penguins %>%
dplyr::count(species) %>%
mutate(pct = n / sum(n)) %>%
ggplot(data = .,
aes(x = species,
y = pct)) +
geom_bar(stat = "identity") +
scale_y_pct()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.