plotPie: Pie chart

Description Usage Arguments See Also Examples

View source: R/plotPie.R

Description

This function draws a pie chart of the values of variable 'Xvar' with the labels from the categorical variable 'Labels'.
Expects aggregated data.

Usage

1
2
3
4
5
6
plotPie(
  .data,
  xvar = "",
  labels = "",
  fill_colors = EcdcColors(col_scale = "qual", n = nrow(.data))
)

Arguments

.data

dataframe containing the variables to plot

xvar

character string, name of the numerical variable to plot in quotes

labels

character string, name of the character variable including the corresponding labels

fill_colors

vector of character strings, hexadecimal colours to use for each labels in the piechart; the vector should contain the exact number of categories defined in "labels" variable. (default to ECDC colors, see EcdcColors(col_scale = "qual", n = nrow(.data)))

See Also

Internal function: EcdcColors
Required Packages: ggplot2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# --- Create dummy data
piechart <- data.frame(Labels = c("Heterosexual females",
                                  "Heterosexual males",
                                  "MSM",
                                  "Unknow"),
                       Values = c(1633,2937,15342,2854))

# --- Plot the dummy data
plotPie(piechart,
         xvar = "Values",
         labels = "Labels")

EU-ECDC/EpiReport documentation built on Feb. 11, 2021, 6:30 p.m.