Title: | Create reproducible reports with quarto and word |
---|---|
Description: | A tool to extend quarto's ability to be a starting point for fully featured word reports. |
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.2.5 |
Built: | 2024-11-19 16:36:38 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, footnotes = NULL, include_object_path = FALSE, footnotes_fail_on_missing_metadata = TRUE, debug = F )
add_footnotes( docx_in, docx_out, figures_path, tables_path, footnotes = NULL, include_object_path = FALSE, footnotes_fail_on_missing_metadata = TRUE, debug = F )
docx_in |
Path to the input .docx file |
docx_out |
Path to output .docx to save to |
figures_path |
Path to images and associated metadata directory |
tables_path |
Path to tables and associated metadata directory |
footnotes |
Path to standard_footnotes.yaml |
include_object_path |
Boolean for including object path path in footnotes |
footnotes_fail_on_missing_metadata |
Boolean for allowing objects to lack metadata and thus have no footnotes |
debug |
Debug |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- file.path(here::here(), "OUTPUTS", "figures") tables_path <- file.path(here::here(), "OUTPUTS", "tables") footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Table addition running add_tables will format and insert tables into the doc. # --------------------------------------------------------------------------- add_tables( docx_in = docx_in, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) # --------------------------------------------------------------------------- # Step 2. # Next we place in 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 to all the inserted figures and tables. # --------------------------------------------------------------------------- add_footnotes( docx_in = doc_dirs$doc_tabs_figs, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, footnotes = footnotes, include_object_path = TRUE footnotes_fail_on_missing_metadata ) ## End(Not run)
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- file.path(here::here(), "OUTPUTS", "figures") tables_path <- file.path(here::here(), "OUTPUTS", "tables") footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Table addition running add_tables will format and insert tables into the doc. # --------------------------------------------------------------------------- add_tables( docx_in = docx_in, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) # --------------------------------------------------------------------------- # Step 2. # Next we place in 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 to all the inserted figures and tables. # --------------------------------------------------------------------------- add_footnotes( docx_in = doc_dirs$doc_tabs_figs, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, footnotes = footnotes, include_object_path = TRUE footnotes_fail_on_missing_metadata ) ## 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, fig_width = NULL, fig_height = NULL, debug = F )
add_plots( docx_in, docx_out, figures_path, fig_width = NULL, fig_height = NULL, debug = F )
docx_in |
Path to the input .docx file |
docx_out |
Path to output .docx to save to |
figures_path |
Path to images file directory |
fig_width |
Figure width in inches. This is a global controller. Defaults to NULL. If NULL, the size is calculated calculated based on the pixels of the actual figure |
fig_height |
Figure height in inches. This is a global controller. Defaults to NULL. If NULL, the size is automatically calculated based on the pixels of the actual figure |
debug |
Debug |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- file.path(here::here(), "OUTPUTS", "figures") tables_path <- file.path(here::here(), "OUTPUTS", "tables") footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Table addition running add_tables will format and insert tables into the doc. # --------------------------------------------------------------------------- add_tables( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) # --------------------------------------------------------------------------- # Step 3. # Next we place in 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 <- file.path(here::here(), "report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- file.path(here::here(), "OUTPUTS", "figures") tables_path <- file.path(here::here(), "OUTPUTS", "tables") footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Table addition running add_tables will format and insert tables into the doc. # --------------------------------------------------------------------------- add_tables( docx_in = doc_dirs$doc_in, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) # --------------------------------------------------------------------------- # Step 3. # Next we place in 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)
Adds tables by looking for magic string
add_tables(docx_in, docx_out, tables_path, debug = F)
add_tables(docx_in, docx_out, tables_path, debug = F)
docx_in |
input doc |
docx_out |
output doc |
tables_path |
path to tables file |
debug |
debug mode |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- file.path(here::here(), "OUTPUTS", "figures") tables_path <- file.path(here::here(), "OUTPUTS", "tables") footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Table addition running add_tables will format and insert tables into the doc. # --------------------------------------------------------------------------- add_tables( docx_in = doc_dirs$doc_clean, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) ## End(Not run)
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) figures_path <- file.path(here::here(), "OUTPUTS", "figures") tables_path <- file.path(here::here(), "OUTPUTS", "tables") footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Table addition running add_tables will format and insert tables into the doc. # --------------------------------------------------------------------------- add_tables( docx_in = doc_dirs$doc_clean, docx_out = doc_dirs$doc_tables, tables_path = tables_path ) ## End(Not run)
Reads in a .docx file and returns an updated version with plots, tables, and footnotes replaced.
build_report( docx_in, docx_out = NULL, figures_path, tables_path, standard_footnotes_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, add_footnotes = TRUE, include_object_path = FALSE, footnotes_fail_on_missing_metadata = TRUE )
docx_in |
Path to input .docx to update |
docx_out |
Path to output .docx to save to |
figures_path |
Path to images file directory |
tables_path |
Path to tables file directory |
standard_footnotes_yaml |
Path to standard_footnotes.yaml in report |
add_footnotes |
boolean for including footnotes in the document or not |
include_object_path |
boolean for including object path in footnotes |
footnotes_fail_on_missing_metadata |
Boolean for allowing objects to lack metadata and thus have no footnotes |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") figures_path <- file.path(here::here(), "OUTPUTS", "figures") tables_path <- file.path(here::here(), "OUTPUTS", "tables") footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Run the wrapper function to replace figures, tables, and footnotes in a # .docx file. # --------------------------------------------------------------------------- build_report( docx_in = docx_in, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, standard_footnotes_yaml = footnotes ) ## End(Not run)
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") figures_path <- file.path(here::here(), "OUTPUTS", "figures") tables_path <- file.path(here::here(), "OUTPUTS", "tables") footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Run the wrapper function to replace figures, tables, and footnotes in a # .docx file. # --------------------------------------------------------------------------- build_report( docx_in = docx_in, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, standard_footnotes_yaml = footnotes ) ## 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)
finalize_document(docx_in, docx_out = NULL)
docx_in |
Path to input .docx to finalize |
docx_out |
Path to output .docx to save to |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") figures_path <- file.path(here::here(), "OUTPUTS", "figures") tables_path <- file.path(here::here(), "OUTPUTS", "tables") footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Run the wrapper function build_report() to replace figures, tables, and # footnotes in a .docx file. # --------------------------------------------------------------------------- build_report( docx_in = docx_in, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, standard_footnotes_yaml = footnotes ) # --------------------------------------------------------------------------- # Step 2. # If you are happy with the report and are ready to finalize the document. # --------------------------------------------------------------------------- finalize_document( docx_in = doc_dirs$doc_draft, docx_out = doc_dirs$doc_final ) ## End(Not run)
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") figures_path <- file.path(here::here(), "OUTPUTS", "figures") tables_path <- file.path(here::here(), "OUTPUTS", "tables") footnotes <- file.path(here::here(), "report", "standard_footnotes.yaml") # --------------------------------------------------------------------------- # Step 1. # Run the wrapper function build_report() to replace figures, tables, and # footnotes in a .docx file. # --------------------------------------------------------------------------- build_report( docx_in = docx_in, docx_out = doc_dirs$doc_draft, figures_path = figures_path, tables_path = tables_path, standard_footnotes_yaml = footnotes ) # --------------------------------------------------------------------------- # Step 2. # If you are happy with the report and are ready to finalize the document. # --------------------------------------------------------------------------- finalize_document( docx_in = doc_dirs$doc_draft, docx_out = doc_dirs$doc_final ) ## End(Not run)
Formats data frames to a flextable specification
format_flextable(data_in, table1_format = F)
format_flextable(data_in, table1_format = F)
data_in |
Data frame to be formatted |
table1_format |
Boolean for using table1 formatting |
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 path to the standard_footnotes.yaml |
A list of meta_abbrevs to be called while performing an analysis
## Not run: meta_abbrevs <- get_meta_abbrevs( path_to_footnotes_yaml = file.path( here::here(), "report", "standard_footnotes.yaml" ) ) ## End(Not run)
## Not run: meta_abbrevs <- get_meta_abbrevs( path_to_footnotes_yaml = file.path( here::here(), "report", "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 path to the standard_footnotes.yaml |
A list of meta_types to be called while performing an analysis
## Not run: meta_type <- get_meta_type( path_to_footnotes_yaml = file.path( here::here(), "report", "standard_footnotes.yaml" ) ) ## End(Not run)
## Not run: meta_type <- get_meta_type( path_to_footnotes_yaml = file.path( here::here(), "report", "standard_footnotes.yaml" ) ) ## 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 |
File name to create on disk |
plot |
Plot to save, defaults to last plot displayed |
meta_type |
Parameter for specifying meta_type for write_object_metadata |
meta_equations |
Parameter for specifying additional equations |
meta_notes |
Parameter for specifying additional notes |
meta_abbrevs |
Parameter for specifying additional abbreviations |
... |
Additional args to be used in ggsave |
## Not run: # Path to the analysis figures (.png) and metadata (.json files) figures_path <- file.path(tempdir(), "figures") # --------------------------------------------------------------------------- # Construct 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 helper function out_name <- "01-12345-pk-timecourse1.png" ggsave_with_metadata( filename = file.path(figures_path, out_name), ) ## End(Not run)
## Not run: # Path to the analysis figures (.png) and metadata (.json files) figures_path <- file.path(tempdir(), "figures") # --------------------------------------------------------------------------- # Construct 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 helper function out_name <- "01-12345-pk-timecourse1.png" ggsave_with_metadata( filename = file.path(figures_path, out_name), ) ## End(Not run)
Initializes python virtual environment
initialize_python()
initialize_python()
## 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)
initialize_report_project(project_dir)
project_dir |
The path to the main directory folder |
## 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 |
Path to the input .docx file |
A list of document paths
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(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 <- file.path(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 |
Path to an object to view its metadata |
A single row data frame consisting of metadata type and footnotes for the object supplied
## Not run: preview_metadata("OUTPUTS/figures/myplot.png") ## End(Not run)
## Not run: preview_metadata("OUTPUTS/figures/myplot.png") ## End(Not run)
Preview all metadata .json files in a directory
preview_metadata_files(file_dir)
preview_metadata_files(file_dir)
file_dir |
Path to a directory containing metadata .json files |
A data frame of metadata footnotes and meta type
## Not run: preview_metadata_file("OUTPUTS/figures/") ## End(Not run)
## Not run: preview_metadata_file("OUTPUTS/figures/") ## 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)
remove_tables_figures_footnotes(docx_in, docx_out)
docx_in |
Path to the input .docx file |
docx_out |
Path to output .docx to save to |
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) # --------------------------------------------------------------------------- # Removal to set-up docx_in # --------------------------------------------------------------------------- remove_tables_figures_footnotes( docx_in = docx_in, docx_out = doc_dirs$doc_clean ) ## End(Not run)
## Not run: # --------------------------------------------------------------------------- # Load all dependencies # --------------------------------------------------------------------------- docx_in <- file.path(here::here(), "report", "shell", "template.docx") doc_dirs <- make_doc_dirs(docx_in = docx_in) # --------------------------------------------------------------------------- # Removal to set-up docx_in # --------------------------------------------------------------------------- remove_tables_figures_footnotes( docx_in = docx_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
validate_object
: 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 = "", meta_type = "NA", meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, table1_format = F, ... )
save_rds_with_metadata( object, file = "", meta_type = "NA", meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, table1_format = F, ... )
object |
R object to serialize |
file |
A connection or the name of the file where the R object is saved to or read from |
meta_type |
The analysis meta type. Defaults to "NA" |
meta_equations |
Additional equations to add to metadata |
meta_notes |
Additional notes to add to metadata |
meta_abbrevs |
Additional abbrevs to add to metadata |
table1_format |
Boolean for declaring object is table1 format |
... |
Additional args to be used in saveRDS |
## Not run: # Path to the analysis tables (.RDS) and metadata (.json files) tables.path <- file.path(tempdir(), "tables") # --------------------------------------------------------------------------- # Save a simple table # --------------------------------------------------------------------------- out_name <- "01-12345-pk-theoph.csv" save_rds_with_metadata( object = Theoph, file = file.path(tables.path, out_name) ) ## End(Not run)
## Not run: # Path to the analysis tables (.RDS) and metadata (.json files) tables.path <- file.path(tempdir(), "tables") # --------------------------------------------------------------------------- # Save a simple table # --------------------------------------------------------------------------- out_name <- "01-12345-pk-theoph.csv" save_rds_with_metadata( object = Theoph, file = file.path(tables.path, out_name) ) ## End(Not run)
Updates the logging level for functions. Default is set to WARN
toggle_logger()
toggle_logger()
## 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, equations = NULL, notes = NULL, abbrevs = NULL )
update_object_footnotes( file_path, overwrite = FALSE, equations = NULL, notes = NULL, abbrevs = NULL )
file_path |
Path to object or object's metadata file |
overwrite |
Boolean to overwrite existing entries or append. Default is to append |
equations |
String or vector of strings of equations to add |
notes |
String or vector of strings of notes to add |
abbrevs |
String or vector of strings of abbreviations to add |
## 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)
Validates a file's hash against a stored hash in the associated _metadata.json file
validate_object(file)
validate_object(file)
file |
A connection or the name of the file where the R object is saved to or read from |
A boolean declaring if the hashes are equal or not
## Not run: tables.path <- "OUTPUTS/tables" out_name <- "01-12345-pk-theoph.csv" validate_object(file = file.path(tables.path, out_name)) ## End(Not run)
## Not run: tables.path <- "OUTPUTS/tables" out_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, meta_type = "NA", meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, table1_format = F, ... )
write_csv_with_metadata( object, file, meta_type = "NA", meta_equations = NULL, meta_notes = NULL, meta_abbrevs = NULL, table1_format = F, ... )
object |
The object to be written, preferably a matrix or data frame. If not, it is attempted to coerce object to a data frame |
file |
Either a character string naming a file or a connection open for writing. "" indicates output to the console. |
meta_type |
The analysis meta type. Defaults to "NA" |
meta_equations |
Additional equations for metadata |
meta_notes |
Additional notes for metadata |
meta_abbrevs |
Additional abbrevs for metadata |
table1_format |
Boolean for declaring table is table1 format |
... |
Additional arguments that can be passed to write.csv |
## Not run: # Path to the analysis tables (.csv) and metadata (.json files) tables.path <- "OUTPUTS/tables" # --------------------------------------------------------------------------------- # Save a simple table # --------------------------------------------------------------------------------- out_name <- "01-12345-pk-theoph.csv" write_csv_with_metadata( object = Theoph, file = file.path(tables.path, out_name), row_names = F ) ## End(Not run)
## Not run: # Path to the analysis tables (.csv) and metadata (.json files) tables.path <- "OUTPUTS/tables" # --------------------------------------------------------------------------------- # Save a simple table # --------------------------------------------------------------------------------- out_name <- "01-12345-pk-theoph.csv" write_csv_with_metadata( object = Theoph, file = file.path(tables.path, out_name), row_names = F ) ## End(Not run)
Writes an object's metadata .json file
write_object_metadata( object_file, meta_type = NULL, equations = NULL, notes = NULL, abbrevs = NULL, table1_format = F )
write_object_metadata( object_file, meta_type = NULL, equations = NULL, notes = NULL, abbrevs = NULL, table1_format = F )
object_file |
Path to the file of the object to write metadata for |
meta_type |
A string denoting what standard notes to use |
equations |
Additional equations to include in metadata, either string of single equation or vector of multiple |
notes |
Additional notes to include in metadata, either string of single note or vector of multiple |
abbrevs |
Additional abbreviations to include in metadata, either string of single abbrev or vector of multiple |
table1_format |
Boolean for using table1 formatting for flextables |
## Not run: ft <- flextable(iris) write_object_metadata(ft, "table", file_path) ## End(Not run)
## Not run: ft <- flextable(iris) write_object_metadata(ft, "table", file_path) ## End(Not run)