Add a slicer to a previously created pivot table. This function is still experimental and might be changed/improved in upcoming releases.
Usage
wb_add_slicer(
wb,
x,
dims = "A1",
sheet = current_sheet(),
pivot_table,
slicer,
params
)
Arguments
- wb
A Workbook object containing a #' worksheet.
- x
A
data.frame
that inherits thewb_data
class.- dims
The worksheet cell where the pivot table is placed
- sheet
A worksheet containing a #'
- pivot_table
The name of a pivot table on the selected sheet
- slicer
A variable used as slicer for the pivot table
- params
A list of parameters to modify pivot table creation. See Details for available options.
Details
This assumes that the slicer variable initialization has happened before. Unfortunately, it is unlikely that we can guarantee this for loaded workbooks, and we strictly discourage users from attempting this. If the variable has not been initialized properly, this may cause the spreadsheet software to crash.
Possible params
arguments are listed below.
edit_as: "twoCell" to place the slicer into the cells
style: "SlicerStyleLight2"
column_count: integer used as column count
caption: string used for a caption
sort_order: "descending" / "ascending"
choose: select variables in the form of a named logical vector like
c(agegp = 'x > "25-34"')
for theesoph
dataset.
See also
Other workbook wrappers:
base_font-wb
,
col_widths-wb
,
creators-wb
,
grouping-wb
,
row_heights-wb
,
wb_add_chartsheet()
,
wb_add_data()
,
wb_add_data_table()
,
wb_add_formula()
,
wb_add_pivot_table()
,
wb_add_worksheet()
,
wb_base_colors
,
wb_clone_worksheet()
,
wb_copy_cells()
,
wb_freeze_pane()
,
wb_merge_cells()
,
wb_save()
,
wb_set_last_modified_by()
,
wb_workbook()
Other worksheet content functions:
col_widths-wb
,
filter-wb
,
grouping-wb
,
named_region-wb
,
row_heights-wb
,
wb_add_conditional_formatting()
,
wb_add_data()
,
wb_add_data_table()
,
wb_add_formula()
,
wb_add_pivot_table()
,
wb_add_thread()
,
wb_freeze_pane()
,
wb_merge_cells()
Examples
wb <- wb_workbook() %>%
wb_add_worksheet() %>% wb_add_data(x = mtcars)
df <- wb_data(wb, sheet = 1)
wb <- wb %>%
wb_add_pivot_table(
df, dims = "A3", slicer = "vs", rows = "cyl", cols = "gear", data = "disp",
pivot_table = "mtcars"
) %>%
wb_add_slicer(x = df, slicer = "vs", pivot_table = "mtcars")