View source: R/make_demographic_table_to_output.R
| make_demographic_table_to_output | R Documentation |
Generates a demographic summary table using 'make_demographic_table()' and exports the resulting table to Word, Excel, or CSV format.
This is a convenience wrapper that combines analysis and output in a single step for users who want immediate file export.
make_demographic_table_to_output(
data,
vars,
continuous_vars = NULL,
file_name = "demographic_table",
format = c("word", "excel", "csv"),
path = NULL
)
data |
A data frame containing the dataset. |
vars |
Character vector of variable names to include in the demographic summary. |
continuous_vars |
Optional character vector specifying which variables should be treated as continuous. If 'NULL', numeric variables are automatically detected. |
file_name |
Name of the output file WITHOUT extension (e.g., "demographics"). |
format |
Output format. Must be one of:
|
path |
Optional character string specifying the directory where the file should be saved. If 'NULL' (default), the file is written to a temporary directory. Provide a full directory path or use getwd() during the function call. |
The demographic table includes:
Categorical variables reported as n (
Continuous variables reported as Mean (SD)
Word export uses 'flextable' and 'officer' for formatting. Excel export uses 'openxlsx'. CSV export uses base R 'write.csv()'.
Invisibly returns the full file path to the generated output file.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.