Skip to contents

Takes 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.

Usage

export_to_word(result, file, title = NULL, author = "EasyStat")

Arguments

result

An object of class "easystat_result" as returned by easy_regression, easy_logistic_regression, easy_ttest, or easy_anova.

file

Character string. Path to the output .docx file. Must be provided by the caller; for example, use tempfile(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.

author

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
# }