Export an EasyStat Result to a Formatted Microsoft Word Document
Source:R/export_to_word.R
export_to_word.RdTakes a unified easystat_result object and writes a fully formatted
.docx report using the flextable and officer packages.
The report contains a title page header, the plain-language narrative,
both statistical tables rendered as professional flextable objects,
and a footer with metadata. All of this is produced in a single function call.
Arguments
- result
An object of class
"easystat_result"as returned byeasy_regression,easy_logistic_regression,easy_ttest, oreasy_anova.- file
Character string. Path to the output
.docxfile. Must be provided by the caller; for example, usetempfile(fileext = ".docx")for a temporary file.- title
Character string. Report title printed at the top of the document. If
NULL(default) a title is auto-generated from the test type.Character string. Author name(s) for the report header. Default
"EasyStat".
Value
The file path invisibly (a length-one character vector). The
.docx file is written to the path supplied via file as a
side-effect.
Examples
# \donttest{
result <- easy_regression(mpg ~ wt + hp, data = mtcars)
export_to_word(result, file = tempfile(fileext = ".docx"),
author = "Mr. Mahesh Divakaran")
#> Word document saved: /private/var/folders/_l/cqt61y8964xcljqfq34qpj3c0000gn/T/RtmpRlFjFu/file23f84356393f.docx
# }