
Create an alluvial plot visualisation from a data frame or a <summarised_result> object.
Source: R/plot.R
alluvialPlot.RdCreate an alluvial plot visualisation from a data frame or a
<summarised_result> object.
Arguments
- result
A
<summarised_result>object.- x
A character vector of column names to use as alluvial axes, in order from left to right. Must contain at least 2 elements.
- y
Column or estimate name that is used as y variable.
- colour
Columns to use to determine the colours.
- facet
Variables to facet by, a formula can be provided to specify which variables should be used as rows and which ones as columns.
- style
Visual theme to apply. Character, or
NULL. If a character, this may be either the name of a built-in style (seeplotStyle()), or a path to a.ymlfile that defines a custom style. IfNULL, the function will use the explicit default style, unless a global style option is set (seesetGlobalPlotOptions()), or a_brand.ymlfile is present (in that order). Refer to the package vignette on styles to learn more.- type
Character string indicating the output plot format. See
plotType()for the list of supported plot types. Iftype = NULL, the function will use the global setting defined viasetGlobalPlotOptions()(if available); otherwise, a standardggplot2plot is produced by default.
Examples
result <- dplyr::tibble(
treatment_1 = c("A", "A", "A", "B", "B", "B", "C", "C"),
treatment_2 = c("A", "A", "B", "A", "B", "B", "B", "C"),
treatment_3 = c("A", "B", "B", "A", "A", "B", "B", "C"),
count = c(22, 3, 5, 7, 3, 17, 4, 12)
)
# basic alluvial plot with 3 axes
alluvialPlot(
result = result,
x = c("treatment_1", "treatment_2", "treatment_3"),
y = "count"
)
#> Warning: Some strata appear at multiple axes.
#> Warning: Some strata appear at multiple axes.
#> Warning: Ignoring empty aesthetic: `family`.
# colour by first axis
alluvialPlot(
result = result,
x = c("treatment_1", "treatment_2", "treatment_3"),
y = "count",
colour = "treatment_1"
)
#> Warning: Some strata appear at multiple axes.
#> Warning: Some strata appear at multiple axes.
#> Warning: Ignoring empty aesthetic: `family`.
# colour by multiple variables
alluvialPlot(
result = result,
x = c("treatment_1", "treatment_2", "treatment_3"),
y = "count",
colour = c("treatment_1", "treatment_2")
)
#> Warning: Some strata appear at multiple axes.
#> Warning: Some strata appear at multiple axes.
#> Warning: Ignoring empty aesthetic: `family`.