GG_proportions: ggplot2 proportions plot

GG_proportionsR Documentation

ggplot2 proportions plot

Description

ggplot2 proportions plot

Usage

GG_proportions(
  x,
  group,
  drop_empty = F,
  stacked = F,
  add_values = F,
  repel = F,
  seed = 1
)

Arguments

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

Value

A ggplot2 of proportions

Examples

#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)

Deleetdk/kirkegaard documentation built on May 2, 2024, 7:12 p.m.