write_methods_doc: Write a methods section document for use with TernTables...

View source: R/write_methods_doc.R

write_methods_docR Documentation

Write a methods section document for use with TernTables output

Description

Generates a Word document containing boilerplate methods text for all three table types produced by TernTables (descriptive, two-group comparison, and three-or-more-group comparison). Each section is headed by a clear label so the user can copy the relevant paragraph directly into a manuscript. When called from ternG, the two-group or multi-group section is populated with the statistical tests that were actually used; all other sections use generic boilerplate. When called from ternD, all comparison sections use generic boilerplate.

Usage

write_methods_doc(
  tbl,
  filename,
  n_levels = 2,
  OR_col = FALSE,
  source = "ternG",
  post_hoc = FALSE
)

Arguments

tbl

A tibble created by ternG or ternD, or NULL when generating a generic document.

filename

Output file path ending in .docx.

n_levels

Number of group levels used in ternG (2 for two-group, 3+ for multi-group). Ignored when called from ternD.

OR_col

Logical; whether odds ratios were calculated. Default FALSE.

source

Character; "ternG" or "ternD". Controls which section is populated with dynamic test information. Default "ternG".

post_hoc

Logical; whether pairwise post-hoc testing was requested (post_hoc = TRUE in ternG). When TRUE and n_levels >= 3, the three-group methods paragraph is updated to describe the post-hoc test pairing (Games-Howell or Dunn's + Holm). Default FALSE.

Value

Invisibly returns the path to the written Word file.

Examples


data(tern_colon)
tbl <- ternG(tern_colon, exclude_vars = c("ID"), group_var = "Recurrence",
            methods_doc = FALSE)
write_methods_doc(tbl, filename = file.path(tempdir(), "methods.docx"))


TernTables documentation built on March 26, 2026, 5:09 p.m.