tests/testthat/helper-example-paths.R

# Source checkouts keep distributed example files under inst/.  R CMD build
# flattens that directory in the source package, so the same files are under
# examples/ while the package's tests are running from a built tarball.
rbiogeme_example_path <- function(...) {
  installed_path <- system.file("examples", package = "rbiogeme")
  if (nzchar(installed_path)) {
    return(file.path(installed_path, ...))
  }

  source_path <- file.path(
    testthat::test_path("..", "..", "inst", "examples"),
    ...
  )
  source_exists <- file.exists(source_path) | dir.exists(source_path)
  if (all(source_exists)) {
    return(source_path)
  }

  file.path(testthat::test_path("..", "..", "examples"), ...)
}

Try the rbiogeme package in your browser

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

rbiogeme documentation built on Sept. 29, 2026, 5:09 p.m.