Converts a crosstable
object into a formatted, savable openxlsx
workbook.
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"), ... )
x
: the result of crosstable()
or a list of crosstablesshow_test_name
: in the test
column, show the test nameby_header
: a string to override the by
headerkeep_id
: whether to keep the .id
columngeneric_labels
: names of the crosstable default columns...
: unusedan 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)
Dan Chaltiel
Useful links