Turns a 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,...)
Arguments
x: the result of crosstable().
keep_id: whether to keep the .id column.
by_header: a string to override the header if x has only one by stratum.
autofit: whether to automatically adjust the table. Can also be a function.
compact: whether to compact the table. If TRUE, see ct_compact.crosstable() to see how to use keep_id.
show_test_name: in the test column, show the test name.
fontsizes: font sizes as a list of keys. Default to list(body=11, subheaders=11, header=11). If set through arguments instead of options, all 3 names should be specified.
padding_v: vertical padding (body).
remove_header_keys: if TRUE and x has several by strata, header will only display values.
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 crosstable_options. See crosstable_options() for details about it. See example for use case.
header_show_n_pattern: glue pattern used when header_show_n==TRUE. .col is the name of the column and .n the size of the group. Default to {.col} (N={.n}); you can also use {.col_key} and {.col_val} when by has multiple stratum. To control the "Total" column, enter this as a list with names "cell" and "total".
generic_labels: names of the crosstable default columns. Useful for translation for instance.
...: unused.
Returns
a flextable.
Methods (by class)
as_flextable(crosstable): Turns a crosstable object into a formatted flextable.