GG_proportions | R Documentation |
ggplot2 proportions plot
GG_proportions(
x,
group,
drop_empty = F,
stacked = F,
add_values = F,
repel = F,
seed = 1
)
x |
A factor variable |
group |
Grouping variable |
drop_empty |
Drop empty combinations |
stacked |
Stacked bar |
add_values |
Add values to the plot |
repel |
Repel the text labels in case of problematic overplotting |
seed |
Seed for the repel algorithm |
A ggplot2 of proportions
#plot the proportions of cylinders by year
GG_proportions(mpg$year, mpg$cyl)
#remove the 0%'s
GG_proportions(mpg$year, mpg$cyl, drop_empty = T)
#stacked
GG_proportions(mpg$year, mpg$cyl, drop_empty = T, stacked = T)
#with values
GG_proportions(mpg$year, mpg$cyl, drop_empty = T, stacked = T, add_values = T)
#with text repel, but it doesn't work so well
GG_proportions(mpg$year, mpg$cyl, drop_empty = T, stacked = T, add_values = T, repel = T)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.