Skip to content

About

Helper functions (control and parsing) for MarkdownReports and ggExpress

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

162 Commits

Folders and files

Repository files navigation

MarkdownHelpers status: active

Helper functions (control and parsing) for MarkdownReports and ggExpress.

Installation

It depends on:

... and provides functions for

You can install all of them directly from GitHub via devtools with one R command:

# install.packages("devtools"); # If you don't have it.

# Install dependencies
devtools::install_github(repo = "vertesy/Stringendo", ref = "main", upgrade = F)
devtools::install_github(repo = "vertesy/CodeAndRoll2", ref = "main", upgrade = F)
devtools::install_github(repo = "vertesy/ReadWriter", ref = "main", upgrade = F)

# Install MarkdownHelpers
devtools::install_github(repo = "vertesy/MarkdownHelpers", ref = "main", upgrade = F)

...then simply load the package:

require("MarkdownHelpers")

Alternatively, you simply source it from the web. This way function help will not work, and you will have no local copy of the code on your hard drive.

source("https://raw.githubusercontent.com/vertesy/MarkdownHelpers/master/R/MarkdownHelpers.R")

Usage

# It is best to load all dependencies:
require('Stringendo')
require('ReadWriter')
require('CodeAndRoll2')
require('MarkdownReports')


require('MarkdownHelpers')
MarkdownReports::setup_MarkdownReports()
# ------------------
"Used by other packages mostly"
Most MarkdownHelpers functions write to a markdown file.
That file is defined in path_of_report by first calling MarkdownReports::setup_MarkdownReports().
MarkdownReports and MarkdownHelpers work with such background variables defined by setup_MarkdownReports() in the global environment.

List of Functions in MarkdownHelpers.R (38)

Updated: 2026/08/25 16:32

  • 1 irequire()

irequire. Load a package. If it does not exist, try to install it from CRAN.

  • 2 unless.specified()

unless.specified. Return value X (TRUE by default) unless the variable is defined. If defined, it returns the variable.

  • 3 TRUE.unless()

TRUE.unless. Return TRUE unless the variable is defined. If defined, it returns the value of the variable.

  • 4 FALSE.unless()

FALSE.unless. Return FALSE unless the variable is defined. If defined, it returns the value of the variable.

  • 5 try_err2warn()

try_err2warn. Evaluate an expression and return its value. If an error occurs, convert the error into an immediate warning and return a fallback value. Execution is never stopped.

  • 6 lookup()

lookup. Awesome pattern matching for a set of values in another set of values. Returns a list with all kinds of results.

  • 7 ww.variable.and.path.exists()

ww.variable.and.path.exists. Check if a variable name is defined, and, if so, does the path (to a file) stored in that variable point to an existing directory?

  • 8 llprint()

llprint. Collapse a sentence from any variables passed to the function with white spaces. Print the sentence to the screen and write it to your markdown report file, if the "path_of_report" variable is defined.

  • 9 llogit()

llogit. Collapse a sentence from any variables passed to the function with white spaces. llogit() writes it to your markdown report file, if the "path_of_report" variable is defined. It does not print the sentence to the screen.

  • 10 md.write.as.list()

md.write.as.list. Writes a vector as a (numbered) list into the report file.

  • 11 md.image.linker()

md.image.linker. Format a markdown image reference (link) to .pdf and .png versions of a graph, and insert both links into the markdown report set by "path_of_report". If the "b.png4GitHub" variable is set, the .png-link is set up such, that you can upload the whole report with the .png image into your GitHub repo's wiki, under "Reports"/OutDir/ (Reports is a literal string, OutDir is the last/deepest directory name in the "OutDir" variable. See create_set_OutDir() function.). This function is called by the ~wplot functions.

  • 12 llwrite_list()

llwrite_list. Print a list object from R, one element per line, into your markdown report.

  • 13 md.import()

md.import. Import and concatenate an external markdown or text file into the report

  • 14 md.LogSettingsFromList()

md.LogSettingsFromList. Log the parameters & settings used in the script and stored in a list, in a table format in the report.

  • 15 md.List2Table()

md.List2Table. Broader variant of md.LogSettingsFromList(). Log the values (col2) from a named (col1) list, in a table format in the report.

  • 16 md.tableWriter.DF.w.dimnames()

md.tableWriter.DF.w.dimnames. Take an R data frame with row and column names, parse a markdown table from it, and write it to the markdown report specified by "path_of_report".

  • 17 md.tableWriter.VEC.w.names()

md.tableWriter.VEC.w.names. Take an R vector with names, parse a markdown table from it, and write it to the markdown report set by "path_of_report".

  • 18 md.LinkTable()

md.LinkTable. Take a data frame where every entry is a string containing an HTML link, parse it, and write out a properly formatted markdown table.

  • 19 md.import.table()

md.import.table. Import a table (.csv, or tab separated values, .tsv file) and write it in markdown format to the report.

  • 20 filter_HP()

filter_HP. Filter values that fall above the high-pass threshold (X >).

  • 21 filter_LP()

filter_LP. Filter values that fall below the low-pass threshold (X <).

  • 22 filter_MidPass()

filter_MidPass. Filter values that fall above the high-pass threshold (X >=) and below the low-pass threshold (X <).

  • 23 ww.FnP_parser()

ww.FnP_parser. Internal function. Parses the full path from the filename and location of the file.

  • 24 ww.variable.and.path.exists()

ww.variable.and.path.exists. Check if a variable name is defined and, if so, does the path (to a file) stored in that variable point to an existing directory?

  • 25 ww.variable.exists.and.true()

ww.variable.exists.and.true. Check if a variable name is defined and, if so, is it TRUE.

  • 26 ww.set.OutDir()

ww.set.OutDir. Checks if global variable OutDir is defined. If not, it returns the current working directory.

  • 27 ww.set.path_of_report()

ww.set.path_of_report. Checks if global variable path_of_report is defined. If not, it defines it as Analysis.md in the current working directory. @importFrom Stringendo iprint @examples ww.set.path_of_report()

  • 28 ww.set.PlotName()

ww.set.PlotName. Generates a plot name (use if none is specified) @importFrom Stringendo iprint @examples ww.set.PlotName()

  • 29 ww.set.mdlink()

ww.set.mdlink. Internal function. Inserts a markdown link to the image (created by the wplot* function that calls this function) only if 'path_of_report' is defined and 'b.mdlink' is TRUE.

  • 30 ww.md.image.link.parser()

ww.md.image.link.parser. Format a markdown image reference (link) from the file path to the file. It can parse the file path if you pass it in separate variables and strings. E.g. ww.md.image.link.parser(Directory, "MyImage.png").

  • 31 ww.ttl_field()

ww.ttl_field. Internal function. Creates the string written into the PDF file "Title" (metadata) field.

  • 32 ww.autoPlotName()

ww.autoPlotName. Internal function. Creates automatic plot and file names.

  • 33 ww.assign_to_global()

ww.assign_to_global. A function loading results to the global environment. Source: https://stackoverflow.com/questions/28180989/

  • 34 try.dev.off()

try.dev.off. Tries to close R graphical devices without raising an error.

  • 35 jjpegA4()

jjpegA4. Set up an A4-sized JPEG.

  • 36 color_check()

color_check. Display the colors encoded by the numbers / color-ID-s you pass on to this function.

  • 37 wcolorize()

wcolorize. Generate color palettes. Input: a vector with categories, can be numbers or strings. Handles repeating values. Output: color vector of equal length as input. Optionally it can output a list where an extra element lists the categories (simply using unique would remove the names). See example. Some color scales depend on packages "colorRamps", or "gplots".

  • 38 filter_survival_length()

filter_survival_length. Parse a sentence reporting the percentage of filter survival.

Function relationships

(of connected functions)

 flowchart LR 

  ww.ttl_field(ww.ttl_field) --> unless.specified(unless.specified)
  ww.set.path_of_report(ww.set.path_of_report) --> ww.variable.and.path.exists(ww.variable.and.path.exists)
  ww.set.mdlink(ww.set.mdlink) --> ww.variable.and.path.exists(ww.variable.and.path.exists)
  ww.set.PlotName(ww.set.PlotName) --> ww.autoPlotName(ww.autoPlotName)
  wcolorize(wcolorize) --> color_check(color_check)
  md.import.table(md.import.table) --> md.tableWriter.DF.w.dimnames(md.tableWriter.DF.w.dimnames)
  md.import(md.import) --> ww.variable.and.path.exists(ww.variable.and.path.exists)
  md.image.linker(md.image.linker) --> unless.specified(unless.specified)
  md.image.linker(md.image.linker) --> llogit(llogit)
  md.LogSettingsFromList(md.LogSettingsFromList) --> md.tableWriter.DF.w.dimnames(md.tableWriter.DF.w.dimnames)
  md.List2Table(md.List2Table) --> md.tableWriter.DF.w.dimnames(md.tableWriter.DF.w.dimnames)
  md.LinkTable(md.LinkTable) --> md.tableWriter.DF.w.dimnames(md.tableWriter.DF.w.dimnames)
  lookup(lookup) --> llprint(llprint)
  llwrite_list(llwrite_list) --> llprint(llprint)
  llwrite_list(llwrite_list) --> llogit(llogit)
  llprint(llprint) --> ww.variable.and.path.exists(ww.variable.and.path.exists)
  filter_survival_length(filter_survival_length) --> llprint(llprint)
  filter_MidPass(filter_MidPass) --> ww.variable.and.path.exists(ww.variable.and.path.exists)
  filter_MidPass(filter_MidPass) --> llogit(llogit)
  filter_LP(filter_LP) --> ww.variable.and.path.exists(ww.variable.and.path.exists)
  filter_LP(filter_LP) --> llogit(llogit)
  llogit(llogit) --> ww.variable.and.path.exists(ww.variable.and.path.exists)
  filter_HP(filter_HP) --> ww.variable.and.path.exists(ww.variable.and.path.exists)
  filter_HP(filter_HP) --> llogit(llogit)
  ww.FnP_parser(ww.FnP_parser) --> ww.set.OutDir(ww.set.OutDir)
  color_check(color_check) --> ww.FnP_parser(ww.FnP_parser)
subgraph SubGraphOne

end
Loading

created by convert_igraph_to_mermaid()


In 2021, function libraries got reorganized as below:

R-package Tree

About

Helper functions (control and parsing) for MarkdownReports and ggExpress

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages