Skip to contents

Read tables from a Word file (docx)

Usage

read_docx_tables(path, docx_header_pattern = NULL, combine = TRUE, ...)

Arguments

path

the path to a Word file (docx).

docx_header_pattern

one or more patterns of required table header names. Can be character or a list containing any combination of character, regex, and fixed patterns. For case-insensitive, use regex.

combine

logical indicating whether to combine the tables into one data frame or return a list of tables.

...

optional arguments passed to read_docx.

Value

a data frame when combined = TRUE; a list of data frames when combined = FALSE.

Examples

if (FALSE) { # \dontrun{

# read and combine all tables from a docx.
read_docx_tables("results.docx")

# read and combine tables from a docx that match a pattern.
read_docx_tables(
  path = "requirements.docx",
  docx_header_pattern = list(
    stringr::regex("variable", ignore_case = TRUE)
  )
)

# optionally, read in with tracked changes accepted or rejected.
read_docx_tables(
  path = "requirements.docx",
  track_changes = "accept"
)
} # }