Skip to content

Remove Tables, Figures, and Footnotes

The remove_tables_figures_footnotes() function in the reportifyr package parses a Microsoft Word document (.docx file) for predefined magic strings, and deletes corresponding tables, figures, and footnotes.


remove_tables_figures_footnotes()

R: Removes Tables, Figures, and Footnotes from a Word file
remove_tables_figures_footnotesR Documentation

Description

Reads in a .docx file and returns a new version with tables, figures, and footnotes removed from the document.

Usage

remove_tables_figures_footnotes(docx_in, docx_out)

Arguments

docx_in

The file path to the input .docx file.

docx_out

The file path to the output .docx file to save to.

Examples

## Not run: 

# ---------------------------------------------------------------------------
# Load all dependencies
# ---------------------------------------------------------------------------
docx_in <- here::here("report", "shell", "template.docx")
doc_dirs <- make_doc_dirs(docx_in = docx_in)

# ---------------------------------------------------------------------------
# Removing tables, figures, and footnotes
# ---------------------------------------------------------------------------
remove_tables_figures_footnotes(
  docx_in = doc_dirs$doc_in,
  docx_out = doc_dirs$doc_clean
)

## End(Not run)

Returns

  • Updated Document: A new .docx file with tables, figures, and footnotes deleted from the appropriate positions.

Logging

  • Debug: Logs the start and end of the function and the start and end of each processx::run().
  • Info: Logs venv_path validation and stdout, stderr and status on succcessful execution of each processx::run().
  • Error: Logs errors for missing docx_in, missing virtual environment (venv_path), and any errors returned from processx::run().

Additional Resources

  • reportifyr GitHub: Refer to the reportifyr repository for more details.
  • processx Reference Manual: Refer to the processx reference manual for specific inquiries related to processx.
  • Initialize Report Project Reference: Refer to the reference on initialize_report_project() here.
  • Make Doc Dirs Reference: Refer to the reference on make_doc_dirs() here.
  • Write Object Metadata Reference: Refer to the reference on write_object_metadata() here.