View source: R/ms_sunburstchart.R
| ms_sunburstchart | R Documentation |
Creation of a sunburst chart object that can be inserted in a 'Microsoft' document. Sunburst charts use the chartEx pipeline (Office 2016+); older versions of 'Microsoft Office' will display a fallback placeholder.
Data is hierarchical: one column per level (parent to leaf, left to right) and one numeric column for the leaf values. Leaf values propagate to parent rings as sums.
ms_sunburstchart(data, path, value, labels = NULL)
data |
a data.frame. |
path |
character vector of column names defining the hierarchy, from outermost (root) to innermost (leaf). |
value |
column name for the numeric leaf values. |
labels |
unused for now; reserved for future custom data label columns. |
An ms_chart object (subclass ms_sunburstchart).
Same caveat as ms_treemapchart(): per-leaf colors via
chart_data_fill() only work reliably with length(path) == 1.
chart_labels(), ms_treemapchart()
Other 'Office' chart objects:
ms_areachart(),
ms_barchart(),
ms_boxplotchart(),
ms_bubblechart(),
ms_chart_combine(),
ms_funnelchart(),
ms_histogramchart(),
ms_linechart(),
ms_paretochart(),
ms_piechart(),
ms_radarchart(),
ms_scatterchart(),
ms_stockchart(),
ms_treemapchart(),
ms_waterfallchart()
library(officer)
dat <- data.frame(
region = c("EU", "EU", "EU", "AM", "AM"),
country = c("FR", "FR", "DE", "US", "US"),
city = c("Paris", "Lyon", "Berlin", "NYC", "LA"),
value = c(10, 5, 12, 20, 8),
stringsAsFactors = FALSE
)
sb <- ms_sunburstchart(
data = dat, path = c("region", "country", "city"), value = "value"
)
doc <- read_pptx()
doc <- add_slide(doc)
doc <- ph_with(doc, sb, location = ph_location_fullsize())
print(doc, target = tempfile(fileext = ".pptx"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.