plotBarGroupedH: Horizontal grouped bar graph

Description Usage Arguments See Also Examples

View source: R/plotBarGroupedH.R

Description

This function draws an horizontal bar graph of the values of variable 'Yvar' with the categorical variable 'Xvar' on the x-axis.
Expects aggregated data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
plotBarGroupedH(
  .data,
  xvar = "",
  xlabel = "",
  yvar = "",
  ylabel = "",
  group = "",
  fill_color = EcdcColors(col_scale = "qual", n = length(unique(.data[[group]]))),
  log10_scale = FALSE
)

Arguments

.data

dataframe containing the variables to plot

xvar

character string, name of the categorical variable to plot on the x-axis in quotes

xlabel

character string, label of the x axis

yvar

character string, name of the numerical variable to plot on the y-axis in quotes

ylabel

character string, label of the y axis

group

character string, name of the grouping variable in quotes, e.g. gender.

fill_color

character string, hexadecimal colour to use in the graph; (default to ECDC green "#65B32E", see EcdcColors(col_scale = "qual", n = 1))

log10_scale

boolean, TRUE if y-axis should be log scale (default FALSE ,see ggplot2::scale_y_log10)

See Also

Internal function: EcdcColors
Required Packages: ggplot2

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# --- Create dummy data
mydat <- data.frame(Gender=c("F", "F", "M", "M"),
                    AgeGroup = c("0-65", "65+", "0-65", "65+"),
                    NumberOfCases = c(54,43,32,41))

# --- Plot the dummy data
plotBarGroupedH(mydat,
              xvar = "AgeGroup",
              xlabel = "Age",
              yvar = "NumberOfCases",
              ylabel = "Number of cases",
              group = "Gender")

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