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")
Run the code above in your browser using DataLab