View source: R/zzz-r4vn-graphs.R View source: R/graphs.R
| gpie | R Documentation |
Draws the distribution of a categorical variable as a pie or donut chart. Bar charts are usually preferable when there are many categories.
gpie(
data = NULL, x = NULL, vars = NULL, by = NULL, donut = FALSE, label = TRUE,
percent = TRUE, digits = 1, xlab = NULL, title = NULL, subtitle = NULL,
note = NULL, color = NULL, palette = "default", alpha = 1,
border_color = "white", border_lwd = 1, clockwise = TRUE, missing = FALSE,
missing_label = "Missing", theme = "journal", size = 11, combine = FALSE,
ncol = NULL, file = NULL, width = 7, height = 5, dpi = 300, show = TRUE,
bg = "white"
)
data |
A data frame. It may be omitted when an active R4VN data frame exists. |
x |
Categorical variable on the horizontal axis. Supply an unquoted name or a character name. |
vars |
Optional |
by |
Optional grouping variable or hierarchical |
donut |
Draw a donut chart instead of a conventional pie. |
label |
Show category labels. |
percent |
Add percentages to labels. |
digits |
Number of percentage decimal places. |
xlab |
Optional category labels. Use an unnamed vector in displayed order or a named vector such as |
title, subtitle, note |
Main title, subtitle, and note. |
color |
A color name or vector of colors. When |
palette |
One of |
alpha |
Color opacity from 0 to 1. |
border_color, border_lwd |
Slice-border colour and line width. |
clockwise |
Draw slices clockwise. |
missing |
Include missing x or by values as a category. |
missing_label |
Label used for missing values. |
theme |
Graph theme: |
size |
Base font size. |
combine |
When several graphs are produced, draw them as labelled panels in one figure. |
ncol |
Optional number of columns in a combined figure. |
file |
Optional output file ending in png, jpg, tiff, pdf, or svg. |
width, height |
Output width and height in inches. |
dpi |
Resolution for raster output. |
show |
Draw the graph in the current graphics device. |
bg |
Background color for exported files. |
Draws one or several categorical variables; by creates separate charts for
group/stratum combinations.
An object of class r4vn_graph; its data component contains counts and percentages.
d <- data.frame(group = c("A", "A", "B", "B", "B", "C"))
gpie(d, x = group)
gpie(d, x = group, donut = TRUE, palette = "journal")
# Extended usage examples
d <- data.frame(group = c("A", "A", "B", "B", "B", "C"))
gpie(d, x = group, show = FALSE)
gpie(d, x = group, donut = TRUE, palette = "journal", show = FALSE)
gpie(d, x = group, label = TRUE, percent = FALSE, show = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.