Learn R Programming

docxtractr (version 0.6.5)

docx_extract_tbl: Extract a table from a Word document

Description

Given a document read with read_docx and a table to extract (optionally indicating whether there was a header or not and if cell whitepace trimming is desired) extract the contents of the table to a data.frame.

Usage

docx_extract_tbl(
  docx,
  tbl_number = 1,
  header = TRUE,
  preserve = FALSE,
  trim = TRUE
)

Arguments

docx

docx object read with read_docx

tbl_number

which table to extract (defaults to 1)

header

assume first row of table is a header row? (default; TRUE)

preserve

preserve line breaks within a cell? Default: FALSE. NOTE: This overrides trim.

trim

trim leading/trailing whitespace (if any) in cells? (default: TRUE)

Value

data.frame

See Also

docx_extract_all, docx_extract_tbl, assign_colnames

Examples

Run this code
# NOT RUN {
doc3 <- read_docx(system.file("examples/data3.docx", package="docxtractr"))
docx_extract_tbl(doc3, 3)

intracell_whitespace <- read_docx(system.file("examples/preserve.docx", package="docxtractr"))
docx_extract_tbl(intracell_whitespace, 2, preserve=FALSE)
docx_extract_tbl(intracell_whitespace, 2, preserve=TRUE)
# }

Run the code above in your browser using DataLab