pie_chart: pie_chart

View source: R/percent_bar.R

pie_chartR Documentation

pie_chart

Description

This function generates a pie chart or a donut chart from the input data. It allows customization of various visual aspects such as colors, labels, and title.

Usage

pie_chart(
  input,
  var,
  var2 = NULL,
  type = 2,
  show_freq = FALSE,
  color = NULL,
  palette = "jama",
  title = NULL,
  text_size = 10,
  title_size = 20,
  add_sum = FALSE
)

Arguments

input

The input dataframe.

var

The variable on which the pie chart or donut chart will be based.

var2

Optional. A secondary variable for creating a donut chart. Default is NULL.

type

The type of chart to be generated. 1 for pie chart, 2 for donut chart, 3 for donut chart based on webr package.

show_freq

Boolean indicating whether to show frequencies on the chart. Default is FALSE.

color

Optional. The color palette for the chart. If not provided, a default color palette will be used.

palette

Optional. The color palette to be used if color is not specified. Default is "jama".

title

Optional. The title of the chart. Default is NULL.

text_size

The size of the text on the chart. Default is 10.

title_size

The size of the title text on the chart. Default is 20.

add_sum

Boolean indicating whether to add the sum of frequencies to the chart. Default is FALSE.

Author(s)

Dongqiang Zeng

Examples

pie_chart(input = sig_stad, var = "Subtype",  palette = "jama")
pie_chart(input = sig_stad, var = "Subtype",  palette = "nrc")

IOBR/IOBR documentation built on May 5, 2024, 2:34 p.m.