From 3ec6d57287faa14185c5627cf423e74b798edcfb Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 28 Aug 2024 19:58:11 +0100 Subject: [PATCH] add input for stan r functions --- R/pcd-stan-tools.R | 14 ++++++++++---- man/pcd_load_stan_functions.Rd | 4 ++++ man/pcd_stan_functions.Rd | 6 +++++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/R/pcd-stan-tools.R b/R/pcd-stan-tools.R index 20e06f9..5250dac 100644 --- a/R/pcd-stan-tools.R +++ b/R/pcd-stan-tools.R @@ -9,12 +9,14 @@ pcd_stan_path <- function() { #' List available Stan functions #' +#' @inheritParams pcd_load_stan_functions #' @return A character vector of available Stan function names #' @export #' @aliases pcd_stan_functions -pcd_stan_functions <- function() { +pcd_stan_functions <- function( + stan_path = primarycensoreddist::pcd_stan_path()) { stan_files <- list.files( - pcd_stan_path(), + stan_path, pattern = "\\.stan$", full.names = TRUE, recursive = TRUE ) @@ -37,6 +39,9 @@ pcd_stan_functions <- function() { #' @param functions Character vector of function names to load. Defaults to all #' functions. #' +#' @param stan_path Character string, the path to the Stan code. Defaults to the +#' path to the Stan code in the primarycensoreddist package. +#' #' @param wrap_in_block Logical, whether to wrap the functions in a #' `functions{}` block. Default is FALSE. #' @@ -50,10 +55,11 @@ pcd_stan_functions <- function() { #' @export #' @aliases pcd_load_stan_functions pcd_load_stan_functions <- function( - functions = NULL, wrap_in_block = FALSE, write_to_file = FALSE, + functions = NULL, stan_path = primarycensoreddist::pcd_stan_path(), + wrap_in_block = FALSE, write_to_file = FALSE, output_file = "pcd_stan_functions.stan") { stan_files <- list.files( - pcd_stan_path(), + stan_paths, pattern = "\\.stan$", full.names = TRUE, recursive = TRUE ) diff --git a/man/pcd_load_stan_functions.Rd b/man/pcd_load_stan_functions.Rd index 633e24b..d4c256f 100644 --- a/man/pcd_load_stan_functions.Rd +++ b/man/pcd_load_stan_functions.Rd @@ -6,6 +6,7 @@ \usage{ pcd_load_stan_functions( functions = NULL, + stan_path = primarycensoreddist::pcd_stan_path(), wrap_in_block = FALSE, write_to_file = FALSE, output_file = "pcd_stan_functions.stan" @@ -15,6 +16,9 @@ pcd_load_stan_functions( \item{functions}{Character vector of function names to load. Defaults to all functions.} +\item{stan_path}{Character string, the path to the Stan code. Defaults to the +path to the Stan code in the primarycensoreddist package.} + \item{wrap_in_block}{Logical, whether to wrap the functions in a \verb{functions\{\}} block. Default is FALSE.} diff --git a/man/pcd_stan_functions.Rd b/man/pcd_stan_functions.Rd index 42b991e..6cc0b77 100644 --- a/man/pcd_stan_functions.Rd +++ b/man/pcd_stan_functions.Rd @@ -4,7 +4,11 @@ \alias{pcd_stan_functions} \title{List available Stan functions} \usage{ -pcd_stan_functions() +pcd_stan_functions(stan_path = primarycensoreddist::pcd_stan_path()) +} +\arguments{ +\item{stan_path}{Character string, the path to the Stan code. Defaults to the +path to the Stan code in the primarycensoreddist package.} } \value{ A character vector of available Stan function names