Defines functions build_report

Documented in build_report

#' Build HTML report
#' Build an HTML report with all the results from the chosen clinical endpoint
#' @param endpoint The clinical endpoint to build the HTML report.
#' @param path Path to write to. It has to be a character string indicating the path and file name (without the extension). For example, `~/Documents/metabolic_report` will save `metabolic_report.html` to the `Documents` folder.
#' @param format The file extension that you want to build the report with. Only `.html`, is supported.
#' @return an HTML file.
#' @export
#' @examples
#' if(interactive()) {
#' # Build an HTML report on VO2max
#' build_report(endpoint = "VO2max", path = tempfile())
#' }
build_report <- function(
  endpoint = c(
    "Flow-mediated Dilation",
    "Body Mass",
    "Body Fat",
    "Systolic Blood Pressure",
    "Diastolic Blood Pressure",
    "Total Cholesterol",
    "C-reactive Protein",
    "Fasting Insulin",
    "Fasting Glucose",
  format = ".html"
) {
  endpoint <- match.arg(endpoint)

  path <- paste0(path, format)

  ## render html file based on template
    input = system.file("endpoint-report-level-1.Rmd", package = "metabolic"),
    output_file = path,
    params = list(endpoint = endpoint)

  ## this will open the file once rendered
  system2("open", path)

Try the metabolic package in your browser

Any scripts or data that you put into this service are public.

metabolic documentation built on Oct. 10, 2023, 9:06 a.m.