Description Usage Arguments Value Warning Examples
stacked_bar_chart
creates a stacked bar chart using the specified library, which can be used in the library's %>% workflow. Data must be provided in long format.
hc_stacked_bar_chart
should not be used directly, it generates a stacked barchart using Plotly.
plotly_stacked_bar_chart
should not be used directly, it generates a stacked barchart using Plotly.
1 2 3 4 5 6 7 | stacked_bar_chart(data, library = "highcharter", categories.column,
categories.order = NA, subcategories.column, value.column,
stacking.type = NA, subcategories.order = NA, return.data = FALSE)
hc_stacked_bar_chart(...)
plotly_stacked_bar_chart(...)
|
data |
A dataframe, must be long-formatted. |
library |
Which library to use, highchart is default. |
categories.column |
Column containing the bar groupings (or categories), in a horizontally orientated barchart these will be the y-axis labels. Must be given as formula, i.e. ~country |
categories.order |
Order for categories to appear in the bar chart, a character vector containing as many unique
categories as there ar in |
subcategories.column |
Column containing different measures, i.e sub-categorisations. Must be given as formula, i.e. ~country |
value.column |
Column containing bar values, i.e. lengths. Must be given as formula, i.e. ~country |
stacking.type |
Stacking to apply to bars, default NULL. Possible values, c("percent", "normal") |
subcategories.order |
Order for sub-categories, note for plotly the legend is ordered correctly but bars are reverse ordered |
return.data |
Useful tool for debugging libraries that perform internal data wrangling, for instance highcharter. If TRUE the function will return the restructured data provided to the htmlwidget generating the output. Default to FALSE. |
... |
all arguments provided to |
Stacked bar chart of the class specified by the specified library.
These should be considered utility functions only, the magic is contained within the htmlwidget library, it is perfectly possible breaking changes to the library and/or the underling JavaScript library will break these. In such case, refer to http://ox-it.github.io/OxfordIDN_htmlwidgets for generic tutorials on the widely used htmlwidget libraries and how to select an alternative visualisation library.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
## Generate a stacked bar chart using highcharter
stacked_bar_chart(data = data_stacked_bar_chart,
library = "highcharter",
categories.column = ~country,
subcategories.column = ~activity,
value.column = ~hours)
## Generate a staced bar chart with bars stacked such that the subcategories totals within a
## category sum to 100%, using plotly.
activity_order <- c("Unclassified", "Business", "Overlay", "Personal", "Teleconference")
country_order <- c("Canada", "China", "Egypt", "Estonia", "France", "Germany", "Ireland",
"Saudi Arabia", "Slovakia", "United Kingdom")
stacked_bar_chart(data = data_stacked_bar_chart,
library = "plotly",
categories.column = ~country,
categories.order = country_order,
subcategories.column = ~activity,
value.column = ~hours,
subcategories.order = activity_order,
stacking.type = "percent")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.