| Title: | Reproducible Reporting Made Simple with R |
|---|---|
| Description: | Create reproducible reports with Microsoft Word and R. |
| Authors: | Jacob Dumbleton [aut, cre], Matthew Smith [aut], Theodoros Papathanasiou [aut], Tarjinder Sahota [aut], Devin Pastoor [aut], Agnes Kim [aut], Anne Zheng [aut], Jenna Johnson [aut], Fernando Carreno [aut], Kashyap Patel [ctb], Maxwell Chirehwa [ctb], Wesley Cummings [ctb], Elizabeth LeBeau [ctb] |
| Maintainer: | Jacob Dumbleton <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.3.4 |
| Built: | 2026-05-21 10:14:54 UTC |
| Source: | https://github.com/a2-ai/reportifyr |
Reads in a .docx file and returns a new version with footnotes placed at appropriate places in the document.
add_footnotes( docx_in, docx_out, figures_path, tables_path, standard_footnotes_yaml = NULL, config_yaml = NULL, include_object_path = FALSE, footnotes_fail_on_missing_metadata = TRUE, debug = FALSE )add_footnotes( docx_in, docx_out, figures_path, tables_path, standard_footnotes_yaml = NULL, config_yaml = NULL, include_object_path = FALSE, footnotes_fail_on_missing_metadata = TRUE, debug = FALSE )
docx_in |
The file path to the input |
docx_out |
The file path to the output |
figures_path |
The file path to the figures and associated metadata directory. |
tables_path |
The file path to the tables and associated metadata directory. |
standard_footnotes_yaml |
The file path to the |
config_yaml |
The file path to the |
include_object_path |
A boolean indicating whether to include the file path of the figure or table in the footnotes. Default is |
footnotes_fail_on_missing_metadata |
A boolean indicating whether to stop execution if the metadata |
debug |
Debug. |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- here::here("OUTPUTS", "figures") tables_path <- here::here("OUTPUTS", "tables") standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # `add_tables()` will format and insert tables into the `.docx` file. # --------------------------------------------------------------------------- add_tables( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) # --------------------------------------------------------------------------- # Step 2. # Next we insert the plots using the `add_plots()` function. # --------------------------------------------------------------------------- add_plots( docx_in = doc_dirs$doc_tables, docx_out = doc_dirs$doc_tabs_figs, figures_path = figures_path ) # --------------------------------------------------------------------------- # Step 3. # Now we can add the footnotes with the `add_footnotes` function. # --------------------------------------------------------------------------- add_footnotes( docx_in = doc_dirs$doc_tabs_figs, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, standard_footnotes_yaml = standard_footnotes_yaml, include_object_path = FALSE, footnotes_fail_on_missing_metadata = TRUE ) ## End(Not run)## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- here::here("OUTPUTS", "figures") tables_path <- here::here("OUTPUTS", "tables") standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # `add_tables()` will format and insert tables into the `.docx` file. # --------------------------------------------------------------------------- add_tables( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) # --------------------------------------------------------------------------- # Step 2. # Next we insert the plots using the `add_plots()` function. # --------------------------------------------------------------------------- add_plots( docx_in = doc_dirs$doc_tables, docx_out = doc_dirs$doc_tabs_figs, figures_path = figures_path ) # --------------------------------------------------------------------------- # Step 3. # Now we can add the footnotes with the `add_footnotes` function. # --------------------------------------------------------------------------- add_footnotes( docx_in = doc_dirs$doc_tabs_figs, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, standard_footnotes_yaml = standard_footnotes_yaml, include_object_path = FALSE, footnotes_fail_on_missing_metadata = TRUE ) ## End(Not run)
Reads in a .docx file and returns a new version with figures placed at appropriate places in the document.
add_plots( docx_in, docx_out, figures_path, config_yaml = NULL, fig_width = NULL, fig_height = NULL, debug = FALSE )add_plots( docx_in, docx_out, figures_path, config_yaml = NULL, fig_width = NULL, fig_height = NULL, debug = FALSE )
docx_in |
The file path to the input |
docx_out |
The file path to the output |
figures_path |
The file path to the figures directory. |
config_yaml |
The file path to the |
fig_width |
A global controller. The figure width in inches. Default is |
fig_height |
A global controller. The figure height in inches. Default is |
debug |
Debug. |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- here::here("OUTPUTS", "figures") tables_path <- here::here("OUTPUTS", "tables") standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # `add_tables()` will format and insert tables into the `.docx` file. # --------------------------------------------------------------------------- add_tables( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) # --------------------------------------------------------------------------- # Step 2. # Next we insert the plots using the `add_plots()` function. # --------------------------------------------------------------------------- add_plots( docx_in = doc_dirs$doc_tables, docx_out = doc_dirs$doc_tabs_figs, figures_path = figures_path ) ## End(Not run)## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- here::here("OUTPUTS", "figures") tables_path <- here::here("OUTPUTS", "tables") standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # `add_tables()` will format and insert tables into the `.docx` file. # --------------------------------------------------------------------------- add_tables( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) # --------------------------------------------------------------------------- # Step 2. # Next we insert the plots using the `add_plots()` function. # --------------------------------------------------------------------------- add_plots( docx_in = doc_dirs$doc_tables, docx_out = doc_dirs$doc_tabs_figs, figures_path = figures_path ) ## End(Not run)
Inserts alt text for figures within a Microsoft Word file.
add_plots_alt_text(docx_in, docx_out, debug = FALSE)add_plots_alt_text(docx_in, docx_out, debug = FALSE)
docx_in |
The file path to the input |
docx_out |
The file path to the output |
debug |
Debug. |
## Not run: add_plots_alt_text("doc-figs.docx", "doc-draft.docx") ## End(Not run)## Not run: add_plots_alt_text("doc-figs.docx", "doc-draft.docx") ## End(Not run)
Reads in a .docx file and returns a new version with tables placed at appropriate places in the document.
add_tables(docx_in, docx_out, tables_path, config_yaml = NULL, debug = FALSE)add_tables(docx_in, docx_out, tables_path, config_yaml = NULL, debug = FALSE)
docx_in |
The file path to the input |
docx_out |
The file path to the output |
tables_path |
The file path to the tables and associated metadata directory. |
config_yaml |
The file path to the |
debug |
Debug. |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- here::here("OUTPUTS", "figures") tables_path <- here::here("OUTPUTS", "tables") standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # `add_tables()` will format and insert tables into the `.docx` file. # --------------------------------------------------------------------------- add_tables( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) ## End(Not run)## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- here::here("OUTPUTS", "figures") tables_path <- here::here("OUTPUTS", "tables") standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # `add_tables()` will format and insert tables into the `.docx` file. # --------------------------------------------------------------------------- add_tables( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) ## End(Not run)
Inserts alt text for tables within a Microsoft Word file.
add_tables_alt_text(docx_in, docx_out, debug = FALSE)add_tables_alt_text(docx_in, docx_out, debug = FALSE)
docx_in |
The file path to the input |
docx_out |
The file path to the output |
debug |
Debug. |
## Not run: add_tables_alt_text("document-tabs.docx", "document-tabs_at.docx") ## End(Not run)## Not run: add_tables_alt_text("document-tabs.docx", "document-tabs_at.docx") ## End(Not run)
Reads in a .docx file and returns a new version with plots, tables, and footnotes replaced.
build_report( docx_in, docx_out = NULL, figures_path, tables_path, standard_footnotes_yaml = NULL, config_yaml = NULL, add_footnotes = TRUE, include_object_path = FALSE, footnotes_fail_on_missing_metadata = TRUE )build_report( docx_in, docx_out = NULL, figures_path, tables_path, standard_footnotes_yaml = NULL, config_yaml = NULL, add_footnotes = TRUE, include_object_path = FALSE, footnotes_fail_on_missing_metadata = TRUE )
docx_in |
The file path to the input |
docx_out |
The file path to the output |
figures_path |
The file path to the figures and associated metadata directory. |
tables_path |
The file path to the tables and associated metadata directory. |
standard_footnotes_yaml |
The file path to the |
config_yaml |
The file path to the |
add_footnotes |
A boolean indicating whether to insert footnotes into the |
include_object_path |
A boolean indicating whether to include the file path of the figure or table in the footnotes. Default is |
footnotes_fail_on_missing_metadata |
A boolean indicating whether to stop execution if the metadata |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- here::here("OUTPUTS", "figures") tables_path <- here::here("OUTPUTS", "tables") standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Run the `build_report()` wrapper function to replace figures, tables, and # footnotes in a `.docx` file. # --------------------------------------------------------------------------- build_report( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, standard_footnotes_yaml = standard_footnotes_yaml ) ## End(Not run)## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- here::here("OUTPUTS", "figures") tables_path <- here::here("OUTPUTS", "tables") standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Run the `build_report()` wrapper function to replace figures, tables, and # footnotes in a `.docx` file. # --------------------------------------------------------------------------- build_report( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, standard_footnotes_yaml = standard_footnotes_yaml ) ## End(Not run)
Reads in a .docx file and returns a finalized version with magic strings and bookmarks removed.
finalize_document(docx_in, docx_out = NULL, config_yaml = NULL)finalize_document(docx_in, docx_out = NULL, config_yaml = NULL)
docx_in |
The file path to the input |
docx_out |
The file path to the output |
config_yaml |
The file path to the |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- here::here("OUTPUTS", "figures") tables_path <- here::here("OUTPUTS", "tables") standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Run the `build_report()` wrapper function to replace figures, tables, and # footnotes in a `.docx` file. # --------------------------------------------------------------------------- build_report( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, standard_footnotes_yaml = standard_footnote_yaml ) # --------------------------------------------------------------------------- # Step 2. # If you are ready to finalize the `.docx` file, run the `finalize_document()` # function. This will remove the ties between reportifyr and the document, so # please be mindful! # --------------------------------------------------------------------------- finalize_document( docx_in = doc_dirs$doc_draft, docx_out = doc_dirs$doc_final ) ## End(Not run)## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- here::here("OUTPUTS", "figures") tables_path <- here::here("OUTPUTS", "tables") standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Run the `build_report()` wrapper function to replace figures, tables, and # footnotes in a `.docx` file. # --------------------------------------------------------------------------- build_report( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, standard_footnotes_yaml = standard_footnote_yaml ) # --------------------------------------------------------------------------- # Step 2. # If you are ready to finalize the `.docx` file, run the `finalize_document()` # function. This will remove the ties between reportifyr and the document, so # please be mindful! # --------------------------------------------------------------------------- finalize_document( docx_in = doc_dirs$doc_draft, docx_out = doc_dirs$doc_final ) ## End(Not run)
Autofits a flextable object, then fits the object to the page width
fit_flextable_to_page(ft, page_width = 6)fit_flextable_to_page(ft, page_width = 6)
ft |
A flextable object |
page_width |
The width of page in inches |
A flextable object fit to page
## Not run: # Load libary for examples: library(flextable) # Create a flextable object and fit to default page width: ft <- flextable(iris) fit_flextable_to_page(ft) # Create a flextable object and specify page width to fit to: ft <- flextable(iris) fit_flextable_to_page(ft, page_width = 6.5) ## End(Not run)## Not run: # Load libary for examples: library(flextable) # Create a flextable object and fit to default page width: ft <- flextable(iris) fit_flextable_to_page(ft) # Create a flextable object and specify page width to fit to: ft <- flextable(iris) fit_flextable_to_page(ft, page_width = 6.5) ## End(Not run)
Formats data frames to a flextable specification
format_flextable(data_in, table1_format = FALSE)format_flextable(data_in, table1_format = FALSE)
data_in |
The input data to be formatted. Must be either a data frame or a flextable object. |
table1_format |
A boolean indicating whether to apply table1-style formatting. Default is |
A formatted flextable
## Not run: dt <- head(iris, 10) format_flextable( data_in = dt ) ## End(Not run)## Not run: dt <- head(iris, 10) format_flextable( data_in = dt ) ## End(Not run)
Get meta abbreviations from standard_footnotes.yaml
get_meta_abbrevs(path_to_footnotes_yaml)get_meta_abbrevs(path_to_footnotes_yaml)
path_to_footnotes_yaml |
The file path to the |
A list of meta_abbrevs to be called while performing an analysis
## Not run: standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") meta_abbrevs <- get_meta_abbrevs(path_to_footnotes_yaml = standard_footnotes_yaml) ## End(Not run)## Not run: standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") meta_abbrevs <- get_meta_abbrevs(path_to_footnotes_yaml = standard_footnotes_yaml) ## End(Not run)
Get meta types from standard_footnotes.yaml
get_meta_type(path_to_footnotes_yaml)get_meta_type(path_to_footnotes_yaml)
path_to_footnotes_yaml |
The file path to the |
A list of meta_type to be called while performing an analysis
## Not run: standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") meta_type <- get_meta_type(path_to_footnotes_yaml = standard_footnotes_yaml) ## End(Not run)## Not run: standard_footnotes_yaml <- here::here("report", "standard_footnotes.yaml") meta_type <- get_meta_type(path_to_footnotes_yaml = standard_footnotes_yaml) ## End(Not run)
get_venv_uv_paths
get_venv_uv_paths()get_venv_uv_paths()
list of paths to uv and venv directory for calling py scripts
## Not run: get_venv_uv_paths() ## End(Not run)## Not run: get_venv_uv_paths() ## End(Not run)
Extension to the ggsave() function that allows capturing object metadata as a separate .json file.
ggsave_with_metadata( filename, plot = ggplot2::last_plot(), meta_type = "NA", meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, ... )ggsave_with_metadata( filename, plot = ggplot2::last_plot(), meta_type = "NA", meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, ... )
filename |
The filename for the plot to save to. |
plot |
The plot object to save. Default is the last displayed plot ( |
meta_type |
A string to specify the type of object. Default is |
meta_equations |
A string or vector of strings representing equations to include in the metadata. Default is |
meta_notes |
A string or vector of strings representing notes to include in the metadata. Default is |
meta_abbrevs |
A string or vector of strings representing abbreviations to include in the metadata. Default is |
... |
Additional arguments passed to the |
## Not run: # --------------------------------------------------------------------------- # Construct and save a simple ggplot # --------------------------------------------------------------------------- g <- ggplot2::ggplot( data = Theoph, ggplot2::aes(x = Time, y = conc, group = Subject) ) + ggplot2::geom_point() + ggplot2::geom_line() + ggplot2::theme_bw() # Save a png using the wrapper function figures_path <- here::here("OUTPUTS", "figures") plot_file_name <- "01-12345-pk-timecourse1.png" ggsave_with_metadata(filename = file.path(figures_path, plot_file_name)) ## End(Not run)## Not run: # --------------------------------------------------------------------------- # Construct and save a simple ggplot # --------------------------------------------------------------------------- g <- ggplot2::ggplot( data = Theoph, ggplot2::aes(x = Time, y = conc, group = Subject) ) + ggplot2::geom_point() + ggplot2::geom_line() + ggplot2::theme_bw() # Save a png using the wrapper function figures_path <- here::here("OUTPUTS", "figures") plot_file_name <- "01-12345-pk-timecourse1.png" ggsave_with_metadata(filename = file.path(figures_path, plot_file_name)) ## End(Not run)
Initializes python virtual environment
initialize_python(continue = NULL)initialize_python(continue = NULL)
continue |
Optional argument to bypass asking user for confirmation to install python deps |
invisibly the metadata_file path
## Not run: initialize_python() ## End(Not run)## Not run: initialize_python() ## End(Not run)
Create report directories within a project
initialize_report_project( project_dir, report_dir_name = NULL, outputs_dir_name = NULL )initialize_report_project( project_dir, report_dir_name = NULL, outputs_dir_name = NULL )
project_dir |
The file path to the main project directory where the directory structure will be created. The directory must already exist; otherwise, an error will be thrown. |
report_dir_name |
The directory name for where reports will be saved.
Default is |
outputs_dir_name |
The directory name for where artifacts will be saved.
Default is |
## Not run: initialize_report_project(project_dir = tempdir()) ## End(Not run)## Not run: initialize_report_project(project_dir = tempdir()) ## End(Not run)
Helper function that defines document output paths
make_doc_dirs(docx_in)make_doc_dirs(docx_in)
docx_in |
The file path to the input |
A list of document paths
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) ## End(Not run)## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- here::here("report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) ## End(Not run)
Previews a single metadata file for an object
preview_metadata(file_name)preview_metadata(file_name)
file_name |
The file path of the file whose metadata you want to preview. |
A single row data frame consisting of metadata type and footnotes for the object supplied
## Not run: figures_path <- here::here("OUTPUTS", "figures") plot_file_name <- "myplot.png" preview_metadata(file.path(figures_path, plot_file_name)) ## End(Not run)## Not run: figures_path <- here::here("OUTPUTS", "figures") plot_file_name <- "myplot.png" preview_metadata(file.path(figures_path, plot_file_name)) ## End(Not run)
Preview all metadata .json files in a directory
preview_metadata_files(file_dir)preview_metadata_files(file_dir)
file_dir |
The file path to a directory containing metadata .json files. |
A data frame of metadata footnotes and meta type
## Not run: figures_path <- here::here("OUTPUTS", "figures") preview_metadata_file(figures_path) ## End(Not run)## Not run: figures_path <- here::here("OUTPUTS", "figures") preview_metadata_file(figures_path) ## End(Not run)
Reads in a .docx file and returns a new version with tables, figures, and footnotes removed from the document.
remove_tables_figures_footnotes(docx_in, docx_out, config_yaml = NULL)remove_tables_figures_footnotes(docx_in, docx_out, config_yaml = NULL)
docx_in |
The file path to the input |
docx_out |
The file path to the output |
config_yaml |
The file path to the |
## 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)## 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)
This pacakge aims to ease table, figure, and footnote insertion and formatting into reports.
initialize_report_project: Creates report directory
with shell, draft, scripts, final subdirectories and adds
standard_footnotes.yaml to /report directory.
Initializes python virtual environment through a subcall to
initialize_python
creates OUTPUTS/figures, OUTPUTS/tables, OUTPUTS/listings directories
initialize_python: Creates virtual environment in
options("venv_dir") if set or project root otherwise.
Also installs python-docx and pyyaml packages.
ggsave_with_metadata: Wrapper for saving ggplot that
also creates metadata for plot object
save_rds_with_metadata: Wrapper for saveRDS that also
creates metadata for tabular object and saves as rtf
write_csv_with_metadata: Wrapper for write.csv that
also creates metadata for tabular object and saves as rtf
save_as_rtf: Saves tabular object (.csv or flextable)
as rtf.
This is called within save_rds_with_metadata and write_csv_with_metadata
format_flextable: Formats a tabular data object as a
flextable with simple formatting.
write_object_metadata: Creates a metadata.json file for
the input object path. Called within all analysis output saving functions.
update_object_footnotes: Used to update footnotes fields
within object metadata json files.
preview_metadata_files: Generates a data frame of all
object metadata within input directory and displays object, meta type, equations
notes, abbreviations.
preview_metadata: Generates the metadata data frame of the
singular input file.
get_meta_type: Generates meta_type object to allow user to
see available meta_types in standard_footnotes.yaml within report directory
get_meta_abbrevs: Generates meta_abbrev object to allow user
to see available abbreviations in standard_footnotes.yaml within report directory.
add_tables: Adds tables into the word document
add_footnotes: Adds footnotes for figures and tables
add_plots: Adds plots into the word document
remove_tables_figures_footnotes: Removes all tables,
figures, and footnotes associated with a magic string {rpfy}:object.ext
remove_magic_strings: Removes all magic strings from a
document cutting its tie to reportifyr but producing a final document.
remove_bookmarks: Removes all bookmarks from document
build_report: Wrapper function to remove old tables,
figures, and footnotes and adds new ones. Calls
remove_tables_figures_footnotes, make_doc_dirs,
add_plots, add_tables, add_footnotes
finalize_document: Wrapper function to remove magic
strings and bookmarks from document.
make_doc_dirs: FILL IN
fit_flextable_to_page: FILL IN
validate_object: FILL IN
validate_config: FILL IN
Maintainer: Jacob Dumbleton [email protected]
Authors:
Matthew Smith [email protected]
Theodoros Papathanasiou [email protected]
Tarjinder Sahota [email protected]
Devin Pastoor [email protected]
Agnes Kim [email protected]
Anne Zheng [email protected]
Jenna Johnson [email protected]
Fernando Carreno [email protected]
Other contributors:
Kashyap Patel [email protected] [contributor]
Maxwell Chirehwa [email protected] [contributor]
Wesley Cummings [email protected] [contributor]
Elizabeth LeBeau [email protected] [contributor]
Useful links:
Extension to the saveRDS() function that allows capturing object metadata as a separate .json file.
save_rds_with_metadata( object, file = "", config_yaml = NULL, meta_type = "NA", meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, table1_format = FALSE, ... )save_rds_with_metadata( object, file = "", config_yaml = NULL, meta_type = "NA", meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, table1_format = FALSE, ... )
object |
The |
file |
The connection or name of the file where the |
config_yaml |
The file path to the |
meta_type |
A string to specify the type of object. Default is |
meta_equations |
A string or vector of strings representing equations to include in the metadata. Default is |
meta_notes |
A string or vector of strings representing notes to include in the metadata. Default is |
meta_abbrevs |
A string or vector of strings representing abbreviations to include in the metadata. Default is |
table1_format |
A boolean indicating whether to apply table1-style formatting. Default is |
... |
Additional arguments passed to the |
## Not run: # --------------------------------------------------------------------------- # Save a simple table # --------------------------------------------------------------------------- tables_path <- here::here("OUTPUTS", "tables") outfile_name <- "01-12345-pk-theoph.RDS" save_rds_with_metadata( object = Theoph, file = file.path(tables_path, outfile_name) ) ## End(Not run)## Not run: # --------------------------------------------------------------------------- # Save a simple table # --------------------------------------------------------------------------- tables_path <- here::here("OUTPUTS", "tables") outfile_name <- "01-12345-pk-theoph.RDS" save_rds_with_metadata( object = Theoph, file = file.path(tables_path, outfile_name) ) ## End(Not run)
Synchronizes report project with config and python dependencies set through options. Uses .report_dir_name_init.json to track differences.
sync_report_project(project_dir, report_dir_name = NULL)sync_report_project(project_dir, report_dir_name = NULL)
project_dir |
The file path to the main project directory where the directory structure will be created. The directory must already exist; otherwise, an error will be thrown. |
report_dir_name |
The directory name for where reports will be saved.
Default is |
## Not run: sync_report_project(here::here()) ## End(Not run)## Not run: sync_report_project(here::here()) ## End(Not run)
Updates the logging level for functions. Default is set to WARN
toggle_logger(quiet = FALSE)toggle_logger(quiet = FALSE)
quiet |
suppresses messaging about log level. |
## Not run: Sys.setenv("RPFY_VERBOSE" = "DEBUG") toggle_logger() ## End(Not run)## Not run: Sys.setenv("RPFY_VERBOSE" = "DEBUG") toggle_logger() ## End(Not run)
Updates an object's footnote metadata - equations, notes, or abbreviations
update_object_footnotes( file_path, overwrite = FALSE, meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL )update_object_footnotes( file_path, overwrite = FALSE, meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL )
file_path |
The file path to the object or its metadata file. |
overwrite |
A boolean indicating whether to overwrite existing metadata entries. Default is |
meta_equations |
A string or vector of strings representing equations to include or overwrite in the metadata. |
meta_notes |
A string or vector of strings representing notes to include or overwrite in the metadata. |
meta_abbrevs |
A string or vector of strings representing abbreviations to include or overwrite in the metadata. |
## Not run: update_object_footnotes("example_metadata.json", equations = c("K10 = CL/VC", "K12 = Q/VC")) ## End(Not run)## Not run: update_object_footnotes("example_metadata.json", equations = c("K10 = CL/VC", "K12 = Q/VC")) ## End(Not run)
Validate alt text of figures/tables against their magic strings in a Microsoft Word file
validate_alt_text_magic_strings(docx_in, debug = FALSE)validate_alt_text_magic_strings(docx_in, debug = FALSE)
docx_in |
The file path to the input |
debug |
Debug. |
## Not run: validate_alt_text_magic_strings("template.docx") ## End(Not run)## Not run: validate_alt_text_magic_strings("template.docx") ## End(Not run)
Validate config.yaml file
validate_config(path_to_config_yaml)validate_config(path_to_config_yaml)
path_to_config_yaml |
The file path to the |
bool TRUE if config is valid, FALSE otherwise.
## Not run: validate_config(here::here("report/config.yaml")) ## End(Not run)## Not run: validate_config(here::here("report/config.yaml")) ## End(Not run)
Validates input Microsoft Word file to ensure proper functionality with reportifyr
validate_docx(docx_in, config_yaml)validate_docx(docx_in, config_yaml)
docx_in |
The file path to the input |
config_yaml |
The file path to the |
## Not run: validate_docx( here::here("report/shell/template.docx"), here::here("report/config.yaml") ) ## End(Not run)## Not run: validate_docx( here::here("report/shell/template.docx"), here::here("report/config.yaml") ) ## End(Not run)
Validates a file's hash against a stored hash in the associated _metadata.json file
validate_object(file)validate_object(file)
file |
The connection or name of the file where the |
A boolean declaring if the hashes are equal or not
## Not run: tables_path <- here::here("OUTPUTS", "tables") outfile_name <- "01-12345-pk-theoph.csv" validate_object(file = file.path(tables_path, out_name)) ## End(Not run)## Not run: tables_path <- here::here("OUTPUTS", "tables") outfile_name <- "01-12345-pk-theoph.csv" validate_object(file = file.path(tables_path, out_name)) ## End(Not run)
Extension to the write.csv() function that allows capturing object metadata as a separate .json file.
write_csv_with_metadata( object, file, config_yaml = NULL, meta_type = "NA", meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, table1_format = FALSE, ... )write_csv_with_metadata( object, file, config_yaml = NULL, meta_type = "NA", meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, table1_format = FALSE, ... )
object |
The |
file |
The connection or name of the file where the |
config_yaml |
The file path to the |
meta_type |
A string to specify the type of object. Default is |
meta_equations |
A string or vector of strings representing equations to include in the metadata. Default is |
meta_notes |
A string or vector of strings representing notes to include in the metadata. Default is |
meta_abbrevs |
A string or vector of strings representing abbreviations to include in the metadata. Default is |
table1_format |
A boolean indicating whether to apply table1-style formatting. Default is |
... |
Additional arguments passed to the |
## Not run: # --------------------------------------------------------------------------------- # Save a simple table # --------------------------------------------------------------------------------- tables_path <- here::here("OUTPUTS", "tables") outfile_name <- "01-12345-pk-theoph.csv" write_csv_with_metadata( object = Theoph, file = file.path(tables_path, out_name), row_names = FALSE ) ## End(Not run)## Not run: # --------------------------------------------------------------------------------- # Save a simple table # --------------------------------------------------------------------------------- tables_path <- here::here("OUTPUTS", "tables") outfile_name <- "01-12345-pk-theoph.csv" write_csv_with_metadata( object = Theoph, file = file.path(tables_path, out_name), row_names = FALSE ) ## End(Not run)
Writes an object's metadata .json file
write_object_metadata( object_file, meta_type = NULL, meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, table1_format = FALSE )write_object_metadata( object_file, meta_type = NULL, meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, table1_format = FALSE )
object_file |
The file path of the object to write metadata for. |
meta_type |
A string to specify the type of object. Default is |
meta_equations |
A string or vector of strings representing equations to include in the metadata. Default is |
meta_notes |
A string or vector of strings representing notes to include in the metadata. Default is |
meta_abbrevs |
A string or vector of strings representing abbreviations to include in the metadata. Default is |
table1_format |
A boolean indicating whether table1 formatting is used for |
## Not run: figures_path <- here::here("OUTPUTS", "figures") plot_file_name <- "01-12345-pk-timecourse1.png" write_object_metadata(object_file = file.path(figures_path, plot_file_name)) ## End(Not run)## Not run: figures_path <- here::here("OUTPUTS", "figures") plot_file_name <- "01-12345-pk-timecourse1.png" write_object_metadata(object_file = file.path(figures_path, plot_file_name)) ## End(Not run)