R/spiro_example.R

Defines functions spiro_example

Documented in spiro_example

#' Get path to spiro example
#'
#' \code{spiro_example} returns the file path for example data files within the
#' \code{spiro} package.
#'
#' @param file Name of the file, either "zan_gxt", "zan_ramp" or "hr_ramp.tcx".
#'   Leave the argument empty to get a vector with the paths of all three
#'   example files.
#'
#' @return A character vector with the absolute file path of the example
#'   file(s).
#'
#' @examples
#' # get path of a specific example data file
#' spiro_example("zan_gxt")
#'
#' # get all paths of example data files
#' spiro_example()
#' @export
spiro_example <- function(file = NULL) {
  if (is.null(file)) {
    path <- system.file("extdata", package = "spiro")
    out <- list.files(path, full.names = TRUE)
  } else {
    out <- system.file("extdata", file, package = "spiro", mustWork = TRUE)
  }
  out
}

Try the spiro package in your browser

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

spiro documentation built on Aug. 14, 2023, 5:07 p.m.