as_flextable.crosstable | R Documentation |
crosstable
object into a formatted flextable
Turns a crosstable
object into a formatted flextable
## S3 method for class 'crosstable'
as_flextable(
x,
keep_id = FALSE,
by_header = NULL,
autofit = TRUE,
compact = FALSE,
show_test_name = TRUE,
fontsizes = list(body = 11, subheaders = 11, header = 11),
padding_v = NULL,
remove_header_keys = TRUE,
header_show_n = FALSE,
header_show_n_pattern = "{.col} (N={.n})",
generic_labels = list(id = ".id", variable = "variable", value = "value", total =
"Total", label = "label", test = "test", effect = "effect"),
...
)
as_flextable(x, ...)
x |
the result of |
keep_id |
whether to keep the |
by_header |
a string to override the header if |
autofit |
whether to automatically adjust the table. Can also be a function. |
compact |
whether to compact the table. If |
show_test_name |
in the |
fontsizes |
font sizes as a list of keys. Default to |
padding_v |
vertical padding (body). |
remove_header_keys |
if |
header_show_n |
numeric vector telling on which depth the group size should be indicated in the header. You can control the pattern using option |
header_show_n_pattern |
glue pattern used when |
generic_labels |
names of the crosstable default columns. Useful for translation for instance. |
... |
unused. |
a flextable.
as_flextable(crosstable)
: Turns a crosstable
object into a formatted flextable
.
Dan Chaltiel
crosstable()
, flextable::flextable()
, as_gt.crosstable()
crosstable_options(crosstable_fontsize_header=14,
crosstable_fontsize_subheaders=10,
crosstable_fontsize_body=8)
crosstable(iris) %>% as_flextable()
crosstable(mtcars2, -model, by=c(am, vs)) %>% as_flextable(header_show_n=1)
crosstable(mtcars2, cols=c(mpg, cyl), by=am, effect=TRUE) %>%
as_flextable(keep_id=TRUE, autofit=FALSE)
crosstable(mtcars2, cols=c(mpg, cyl), by=am, effect=TRUE, total=TRUE) %>%
as_flextable(compact=TRUE, header_show_n=TRUE,
header_show_n_pattern=list(cell="{.col} (N={.n})", total="Total\n(N={.n})"))
#Renaming (because why not?)
crosstable(mtcars2, am, by=vs, total="both", test=TRUE, effect=TRUE) %>%
dplyr::rename(ID=.id, math=variable, Tot=Total, lab=label, pval=test, fx=effect) %>%
as_flextable(by_header = "Engine shape",
generic_labels=list(id = "ID", variable = "math", total="Tot",
label = "lab", test = "pval", effect="fx"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.