crosstable object into a formatted, savable openxlsx workbook.R/openxlsx.R
as_workbook.RdConverts a crosstable object into a formatted, savable openxlsx workbook.
as_workbook(
x,
show_test_name = TRUE,
by_header = NULL,
keep_id = FALSE,
generic_labels = list(id = ".id", variable = "variable", value = "value", total =
"Total", label = "label", test = "test", effect = "effect"),
...
)the result of crosstable() or a list of crosstables
in the test column, show the test name
a string to override the by header
whether to keep the .id column
names of the crosstable default columns
unused
an openxlsx workbook containing the crosstable(s)
library(openxlsx)
target = tempfile(fileext=".xlsx")
x=crosstable(mtcars2, c(mpg, vs, gear), total=TRUE, test=TRUE)
as_workbook(x, keep_id=TRUE) %>%
saveWorkbook(file=target)
if(interactive()) browseURL(target)
target = tempfile(fileext=".xlsx")
x2=list(iris=crosstable(iris2), crosstable(mtcars2))
as_workbook(x2, keep_id=TRUE) %>%
saveWorkbook(file=target)
if(interactive()) browseURL(target)