Package 'subreport'

Title: Generate Reports from `subfoldr2` Objects
Description: Facilitates generation of .Rmd and .html reports from tables, (code) blocks and figures (plots and windows) saved using the subfoldr2 package. To quickly view all the results use `sbr_knit_results()`. The `sbr_n()` and `sbr_s()` functions can be used to insert numbers or strings saved using subfoldr2.
Authors: Joe Thorley [aut, cre] (ORCID: <https://orcid.org/0000-0002-7683-4592>), Seb Dalgarno [aut] (ORCID: <https://orcid.org/0000-0002-3658-4517>), Duncan Kennedy [ctb] (ORCID: <https://orcid.org/0009-0001-4880-5751>), Poisson Consulting [cph, fnd]
Maintainer: Joe Thorley <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2026-06-01 05:04:29 UTC
Source: https://github.com/poissonconsulting/subreport

Help Index


Blocks

Description

Returns a string of the report code blocks in markdown format ready for inclusion in a report.

Usage

sbr_blocks(
  x_name = ".*",
  sub = character(0),
  report = sbr_get_report(),
  tag = ".*",
  drop = NULL,
  keep = NULL,
  sort = NULL,
  rename = NULL,
  nheaders = 2L,
  header1 = 4L,
  main = subfoldr2::sbf_get_main()
)

Arguments

x_name

A string of the regular expression to match file names.

sub

A string of the path to the root sub folder.

report

A string of the path to the report folder.

tag

A string of the regular expression that the tag must match to be included.

drop

A character vector specifying the sub folders and file names to exclude from the report or NULL.

keep

A character vector specifying the highest level sub folders to keep that are not in drop. If NULL all highest level subfolders that are not in drop are kept.

sort

A character vector specifying the initial sort order for sub folders and file names or NULL. Missing items appear afterwards in alphabetical order.

rename

A unique named character vector specifying new heading names for sub folders or NULL. By default sub folder names have the first letter of each word capitalized.

nheaders

A count of the number of sub folder levels to assign headers to.

header1

A count of the heading level for the first sub folder level.

main

A string of the path to the main folder.

Value

A string of the code blocks in markdown format.


Figures

Description

Returns a string of the report plots and windows in markdown format ready for inclusion in a report. If a window and plot have identical names then the plot is dropped.

Usage

sbr_figures(
  x_name = ".*",
  sub = character(0),
  report = sbr_get_report(),
  tag = ".*",
  drop = NULL,
  keep = NULL,
  sort = NULL,
  rename = NULL,
  nheaders = 2L,
  header1 = 4L,
  main = subfoldr2::sbf_get_main(),
  width = 6,
  pre_num = getOption("sbr.pre_num_fig", 0L)
)

Arguments

x_name

A string of the regular expression to match file names.

sub

A string of the path to the root sub folder.

report

A string of the path to the report folder.

tag

A string of the regular expression that the tag must match to be included.

drop

A character vector specifying the sub folders and file names to exclude from the report or NULL.

keep

A character vector specifying the highest level sub folders to keep that are not in drop. If NULL all highest level subfolders that are not in drop are kept.

sort

A character vector specifying the initial sort order for sub folders and file names or NULL. Missing items appear afterwards in alphabetical order.

rename

A unique named character vector specifying new heading names for sub folders or NULL. By default sub folder names have the first letter of each word capitalized.

nheaders

A count of the number of sub folder levels to assign headers to.

header1

A count of the heading level for the first sub folder level.

main

A string of the path to the main folder.

width

A number of the page width in inches.

pre_num

A count specifying the number of pre-existing items.

Value

A string of the plots in markdown format.


Get Report

Description

Get Report

Usage

sbr_get_report()

Value

A string specifying the report directory.

Examples

sbr_get_report()

Knit Report

Description

Makes a results .Rmd file of the tables, code blocks and plots (and windows) and knits it into a .html file and opens in the default web browser.

Usage

sbr_knit_results(
  file = "results",
  report = sbr_get_report(),
  sub = character(0),
  main = subfoldr2::sbf_get_main(),
  quiet = FALSE,
  browse = TRUE,
  browser = "open"
)

Arguments

file

A string of the file name(s) without an extension.

report

A string of the directory to save the tables, code blocks and plots.

sub

A string specifying the path to the sub folder (by default the current sub folder).

main

A string specifying the path to the main folder (by default the current main folder)

quiet

An option to suppress printing during rendering from knitr, pandoc command line and others. To only suppress printing of the last "Output created: " message, you can set rmarkdown.render.message to FALSE

browse

A flag specifying whether to open the .html file in a web browser.

browser

a non-empty character string giving the name of the program to be used as the HTML browser. It should be in the PATH, or a full path specified. Alternatively, an R function to be called to invoke the browser.

Under Windows NULL is also allowed (and is the default), and implies that the file association mechanism will be used.

Value

An invisible path to the .Rmd file.


Get Number

Description

Get Number

Usage

sbr_number(x_name, sub = character(0))

sbr_n(x_name, sub = character(0))

Arguments

x_name

A string of the name.

sub

A string specifying the path to the sub folder (by default the current sub folder).

Value

A number.


Numbers

Description

Returns a string of the numbers in markdown list(s) format ready for inclusion in a report.

Usage

sbr_numbers(
  x_name = ".*",
  sub = character(0),
  report = sbr_get_report(),
  tag = ".*",
  drop = NULL,
  keep = NULL,
  sort = NULL,
  rename = NULL,
  nheaders = 2L,
  header1 = 4L,
  numbered = FALSE,
  main = subfoldr2::sbf_get_main()
)

Arguments

x_name

A string of the regular expression to match file names.

sub

A string of the path to the root sub folder.

report

A string of the path to the report folder.

tag

A string of the regular expression that the tag must match to be included.

drop

A character vector specifying the sub folders and file names to exclude from the report or NULL.

keep

A character vector specifying the highest level sub folders to keep that are not in drop. If NULL all highest level subfolders that are not in drop are kept.

sort

A character vector specifying the initial sort order for sub folders and file names or NULL. Missing items appear afterwards in alphabetical order.

rename

A unique named character vector specifying new heading names for sub folders or NULL. By default sub folder names have the first letter of each word capitalized.

nheaders

A count of the number of sub folder levels to assign headers to.

header1

A count of the heading level for the first sub folder level.

numbered

A flag specifying whether the list(s) items should be numbered.

main

A string of the path to the main folder.

Value

A string of the numbers in markdown format.


Reset Report

Description

Reset Report

Usage

sbr_reset_report(rm = FALSE, ask = getOption("sbr.ask", TRUE))

Arguments

rm

A flag specifying whether to remove the folder and all its contents if it already exists.

ask

A flag specifying whether to ask before removing the existing folder.

Value

An invisible copy of the string "report".


Set Report

Description

The directory is created when needed if it doesn't already exist.

Usage

sbr_set_report(..., rm = FALSE, ask = getOption("sbf.ask", TRUE))

Arguments

...

One or more character vectors which are combined together.

rm

A flag specifying whether to remove the folder and all its contents if it already exists.

ask

A flag specifying whether to ask before removing the existing folder.

Value

An invisible string of the path to the main folder.


Get String

Description

Get String

Usage

sbr_string(x_name, sub = character(0))

sbr_s(x_name, sub = character(0))

Arguments

x_name

A string of the name.

sub

A string specifying the path to the sub folder (by default the current sub folder).

Value

A string.


Strings

Description

Returns a string of the report strings in markdown list(s) format ready for inclusion in a report.

Usage

sbr_strings(
  x_name = ".*",
  sub = character(0),
  report = sbr_get_report(),
  tag = ".*",
  drop = NULL,
  keep = NULL,
  sort = NULL,
  rename = NULL,
  nheaders = 2L,
  header1 = 4L,
  numbered = FALSE,
  main = subfoldr2::sbf_get_main()
)

Arguments

x_name

A string of the regular expression to match file names.

sub

A string of the path to the root sub folder.

report

A string of the path to the report folder.

tag

A string of the regular expression that the tag must match to be included.

drop

A character vector specifying the sub folders and file names to exclude from the report or NULL.

keep

A character vector specifying the highest level sub folders to keep that are not in drop. If NULL all highest level subfolders that are not in drop are kept.

sort

A character vector specifying the initial sort order for sub folders and file names or NULL. Missing items appear afterwards in alphabetical order.

rename

A unique named character vector specifying new heading names for sub folders or NULL. By default sub folder names have the first letter of each word capitalized.

nheaders

A count of the number of sub folder levels to assign headers to.

header1

A count of the heading level for the first sub folder level.

numbered

A flag specifying whether the list(s) items should be numbered.

main

A string of the path to the main folder.

Value

A string of the code blocks in markdown format.


Tables

Description

Returns a string of the report tables in markdown format ready for inclusion in a report.

Usage

sbr_tables(
  x_name = ".*",
  sub = character(0),
  report = sbr_get_report(),
  tag = ".*",
  drop = NULL,
  keep = NULL,
  sort = NULL,
  rename = NULL,
  nheaders = 2L,
  header1 = 4L,
  main = subfoldr2::sbf_get_main(),
  sigfig = 4L,
  sigfig_override = NULL
)

Arguments

x_name

A string of the regular expression to match file names.

sub

A string of the path to the root sub folder.

report

A string of the path to the report folder.

tag

A string of the regular expression that the tag must match to be included.

drop

A character vector specifying the sub folders and file names to exclude from the report or NULL.

keep

A character vector specifying the highest level sub folders to keep that are not in drop. If NULL all highest level subfolders that are not in drop are kept.

sort

A character vector specifying the initial sort order for sub folders and file names or NULL. Missing items appear afterwards in alphabetical order.

rename

A unique named character vector specifying new heading names for sub folders or NULL. By default sub folder names have the first letter of each word capitalized.

nheaders

A count of the number of sub folder levels to assign headers to.

header1

A count of the heading level for the first sub folder level.

main

A string of the path to the main folder.

sigfig

A positive integer of the significant figures to use when formatting numbers. This is applied to all tables.

sigfig_override

A named vector of table names and the number of significant figures to use. This will override the default set in sigfig for matching tables.

Value

A string of the tables in markdown format.


Use Bibliography

Description

Creates a bibliography.bib file in the root directory.

Usage

sbr_use_bibliography()

Use Knit Report

Description

Creates a knit-report.R file in the root directory.

Usage

sbr_use_knit_report()

Use Knit Report All

Description

Creates knit-report.R, bibliography.bib and and knit-report.R files in the root directory.

Usage

sbr_use_knit_report_all()

Use Report File

Description

Creates a report.Rmd file in the root directory.

Usage

sbr_use_report()