Description Usage Arguments See Also Examples
View source: R/plotBarGroupedH.R
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.
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
)
|
.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 |
log10_scale |
boolean, TRUE if y-axis should be log scale
(default |
Internal function: EcdcColors
Required Packages: ggplot2
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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.