Learn R Programming

openxlsx2 (version 0.7)

wb_add_pivot_table: Add pivot table to a worksheet

Description

add pivot table

Usage

wb_add_pivot_table(
  wb,
  x,
  sheet = next_sheet(),
  dims = "A3",
  filter,
  rows,
  cols,
  data,
  fun,
  params
)

Arguments

wb

A Workbook object containing a #' worksheet.

x

a wb_data object

sheet

a worksheet

dims

the worksheet cell where the pivot table is placed

filter

a character object with names used to filter

rows

a character object with names used as rows

cols

a character object with names used as cols

data

a character object with names used as data

fun

a character object of functions to be used with the data

params

a list of parameters to modify pivot table creation

Details

fun can be either of AVERAGE, COUNT, COUNTA, MAX, MIN, PRODUCT, STDEV, STDEVP, SUM, VAR, VARP.

The sheet will be empty unless it is opened in spreadsheet software.

See Also

Other workbook wrappers: wb_add_chartsheet(), wb_add_data_table(), wb_add_data(), wb_add_formula(), wb_add_worksheet(), wb_clone_worksheet(), wb_copy_cells(), wb_creators, wb_freeze_pane(), wb_get_base_font(), wb_save(), wb_set_col_widths(), wb_set_last_modified_by(), wb_set_row_heights(), wb_workbook(), workbook_grouping, ws_cell_merge

Examples

Run this code
wb <- wb_workbook() %>% wb_add_worksheet() %>% wb_add_data(x = mtcars)

df <- wb_data(wb)

wb <- wb %>%
wb_add_pivot_table(df, dims = "A3",
  filter = "am", rows = "cyl", cols = "gear", data = "disp")

Run the code above in your browser using DataLab