Skip to contents

Creation of a funnel chart object that can be inserted in a 'Microsoft' document. Funnel charts use the chartEx pipeline (Office 2016+); older versions of 'Microsoft Office' will display a fallback placeholder.

Each row is one stage of the funnel. Values are typically decreasing (e.g. visitors -> leads -> customers). Bars are centered horizontally and width is proportional to the value.

Usage

ms_funnelchart(data, x, y)

Arguments

data

a data.frame.

x

category column name (stage label).

y

numeric value column name.

Value

An ms_chart object (subclass ms_funnelchart).

Examples

library(officer)

dat <- data.frame(
  stage = c("Visitors", "Leads", "Opportunities", "Quotes", "Customers"),
  count = c(5000, 4000, 3000, 1000, 250),
  stringsAsFactors = FALSE
)
fn <- ms_funnelchart(data = dat, x = "stage", y = "count")

doc <- read_pptx()
doc <- add_slide(doc)
#> Warning: Calling `add_slide()` without specifying a `layout` is deprecated.
#>  Please pass a `layout` or use `layout_default()` to set a default.
#>  => I will now continue with the former `layout` default "Title and Content" for backwards compatibility...
doc <- ph_with(doc, fn, location = ph_location_fullsize())
print(doc, target = tempfile(fileext = ".pptx"))