plot_pie: Plot Pie Chart

View source: R/plot_count.R

plot_pieR Documentation

Plot Pie Chart

Description

High level constructor of pie chart using ggplot2 to display count of 1 variable.

Usage

plot_pie(
  data = NULL,
  var,
  lump_prop = 0,
  other_level = "Other",
  polar_start = 0,
  polar_direction = 1,
  polar_clip = "on",
  label_geom = c("label", "label_repel", "text", "text_repel"),
  label_number = c("percent", "count", "both"),
  color_label = "black",
  ...
)

Arguments

data

A data.frame

var

(Quote or Unquote) Categorical variables to plot

lump_prop

Proportion that lump levels to "Other" (passed to fct_lump at prop argument)

other_level

Name of the "Other" level

polar_start

The start arg of the coord_polar()

polar_direction

The direction arg of the coord_polar(): 1 for clockwise rotation from high-to-low count.

polar_clip

The clip arg of the coord_polar()

label_geom

(A Character) Indicate function of label geom

  • "label": geom_label

  • "label_repel": ggrepel::geom_label_repel

  • "text": geom_text

  • "text_repel": ggrepel::geom_text_repel

label_number

(A Character) How to display the label?

  • "percent": use ⁠%⁠ (eg. 60%)

  • "count": count as integer (eg. 6)

  • "both": use ⁠%⁠ and count in parenthesis (eg. 60% (6))

color_label

(A Character) Color for label

...

Passed to selected function of label_geom

Value

A Plot class gg and ggplot

Examples

plot_pie(mtcars, cyl)

Lightbridge-KS/lbx documentation built on Dec. 4, 2024, 2:53 a.m.