Learn R Programming

tableParser (version 1.0.2)

docx2matrix: docx2matrix

Description

Extracts tables from DOCX documents and returns a list of character matrices.

Usage

docx2matrix(x, unifyMatrix = TRUE, replicate = TRUE)

Value

List with extracted tables as character matrices.

Arguments

x

File path to a DOCX input file with tables.

unifyMatrix

Logical. If TRUE, matrix cells are unified for better post-processing (see 'unifyMatrixContent()').

replicate

Logical. If TRUE, replicates content when splitting connected cells.

Examples

Run this code
## Download an example DOCX file from tableParser's github repo to temp directory 
d<-'https://github.com/ingmarboeschen/tableParser/raw/refs/heads/main/tableExamples.docx'
# for Windows
if(grepl("[A-Z]:",tempdir()))
   download.file(d,paste0(tempdir(),"/","tableExamples.docx"),method="wget")
# all other machines
if(!grepl("[A-Z]:",tempdir()))
   download.file(d,paste0(tempdir(),"/","tableExamples.docx"))
Sys.sleep(.2)

# Extract tables as character matrices
docx2matrix(paste0(tempdir(),"/","tableExamples.docx"))

Run the code above in your browser using DataLab