Description Usage Arguments Value Examples
View source: R/plotgg_stacked_columns.r
Takes a data frame or tibble with one row per observation and multiple variables (columns) per observation. It then plots the selected variables as stacked bars per observation, possibly faceting the plot.
1 2 3 4 5 6 7 8 9 10 11 12 13 | plotgg_stacked_columns(
dat,
x,
columns = NULL,
facet_formula = NULL,
gather_key = "key",
gather_value = "value",
custom_theme = ggplot2::theme(panel.background = ggplot2::element_blank(), panel.grid
= ggplot2::element_blank(), axis.text = ggplot2::element_text(color = "black"),
axis.title = ggplot2::element_text(color = "black", face = "bold"),
axis.line.x.bottom = ggplot2::element_line(), axis.line.y.left =
ggplot2::element_line())
)
|
dat |
A data frame or tibble with one row per observation and multiple variables (i.e. columns) per observations. |
x |
The name of the column to be used as an observation name. It will be used to as a label in the x axis of the plot. |
columns |
A character vector containing the names of the columns to stack. If NULL, all columns except for the column indicated by 'x' and the columns in 'facet_formula' will be included. |
facet_formula |
A formula to be used by facet_grid. It will split the stacked bars into panels. |
gather_key |
The key name to be used by gather. It will indicate the name for the gathered columns. The text itself will be used as the legend title. |
gather_value |
The value name to be used by gather. It will indicate the sum of values in the stacked bars. The text itself will be used as the y-axis title. |
custom_theme |
The result of a call to theme. It allows for control over the plot format |
A ggplot2 plot.
1 2 3 4 5 6 7 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.