R/load_stan_file.R

Defines functions load_stan_file

Documented in load_stan_file

#' Load a Stan `psborrow2` template
#'
#' This function loads a Stan template file from the package's 'inst/stan' directory.
#' @param ... subidrectories
#' @return template string
load_stan_file <- function(...) {
  # Construct the path within the package
  template_path <- system.file("stan", ..., package = "psborrow2")
  
  # Check if the file exists
  if (template_path == "") {
    stop("Template file not found at path: ", file.path("inst/stan", ...))
  }
  
  # Read the content of the file
  template_content <- paste(readLines(template_path), collapse = "\n")
  
  return(template_content)
}

Try the psborrow2 package in your browser

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

psborrow2 documentation built on April 4, 2025, 12:37 a.m.