Learn R Programming

tidyplots (version 0.2.1)

add_pie: Add pie or donut chart

Description

Add pie or donut chart

Usage

add_pie(plot, width = 1, reverse = FALSE, ...)

add_donut(plot, width = 1, reverse = FALSE, ...)

Value

A tidyplot object.

Arguments

plot

A tidyplot generated with the function tidyplot().

width

Width of the plot area. Defaults to 50.

reverse

Whether the order should be reversed or not. Defaults to FALSE, meaning not reversed.

...

Arguments passed on to the geom function.

Examples

Run this code
# for a `count` only provide `color`
# `count` of the data points in each `energy_type` category
energy %>%
  tidyplot(color = energy_type) %>%
  add_pie()

energy %>%
  tidyplot(color = energy_type) %>%
  add_donut()

# for a `sum` provide `color` and `y`
# `sum` of `energy` in each `energy_type` category
energy %>%
  tidyplot(y = energy, color = energy_type) %>%
  add_pie()

energy %>%
  tidyplot(y = energy, color = energy_type) %>%
  add_donut()

Run the code above in your browser using DataLab