Title: | Facilitating the Use of 'Stan' Within Packages |
Version: | 0.0.4 |
Description: | Infrastructure and functions that can be used for integrating 'Stan' (Carpenter et al. (2017) <doi:10.18637/jss.v076.i01>) code into stand alone R packages which in turn use the 'CmdStan' engine which is often accessed through 'CmdStanR'. Details given in Stan Development Team (2025) https://mc-stan.org/cmdstanr/. Using 'CmdStanR' and pre-written 'Stan' code can make package installation easy. Using 'staninside' offers a way to cache user-compiled 'Stan' models in user-specified directories reducing the need to recompile the same model multiple times. |
License: | MIT + file LICENSE |
URL: | https://github.com/medewitt/staninside, https://medewitt.github.io/staninside/ |
BugReports: | https://github.com/medewitt/staninside/issues |
Encoding: | UTF-8 |
RoxygenNote: | 7.3.2 |
Depends: | R (≥ 3.1) |
Suggests: | knitr, covr, spelling, testthat (≥ 3.0.0), rmarkdown |
Imports: | cli, fs, rappdirs |
Language: | en-US |
Config/testthat/edition: | 3 |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2025-07-28 14:54:18 UTC; michael |
Author: | Michael DeWitt |
Maintainer: | Michael DeWitt <me.dewitt.jr@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-07-30 08:30:02 UTC |
staninside: Facilitating the Use of 'Stan' Within Packages
Description
Infrastructure and functions that can be used for integrating 'Stan' (Carpenter et al. (2017) doi:10.18637/jss.v076.i01) code into stand alone R packages which in turn use the 'CmdStan' engine which is often accessed through 'CmdStanR'. Details given in Stan Development Team (2025) https://mc-stan.org/cmdstanr/. Using 'CmdStanR' and pre-written 'Stan' code can make package installation easy. Using 'staninside' offers a way to cache user-compiled 'Stan' models in user-specified directories reducing the need to recompile the same model multiple times.
Author(s)
Maintainer: Michael DeWitt me.dewitt.jr@gmail.com (ORCID)
See Also
Useful links:
Report bugs at https://github.com/medewitt/staninside/issues
Clear Stan Cache
Description
This function clears anything that may exist in the Stan Cache. Most Commonly if you are using the CmdStan backend, you'll have items in your cache.
Usage
clear_stan_cache(pkgname)
Arguments
pkgname |
a string, the name of the package |
Value
invisible null
Warning
This will removed cached models and requires that rappdirs
is installed
Copy Stan Models
Description
This function extracts the Stan Code from a Package and then copies it to your user cache locally.
Usage
copy_models(pkgname = "staninside", local_location = NULL)
Arguments
pkgname |
a string, the name of the package |
local_location |
a file path representing the desired location of the local copy. If "default" is provided, the function will use the user cache directory for the package. |
Value
file path of newly created files
Examples
local_location <- tempdir()
copy_models(pkgname = "staninside", local_location = local_location)
Find Stan Code
Description
This function looks for Stan code within a given R package a returns a list with the Stan code location within the package and the text of the code,
Usage
find_stan_code(pkgname = "staninside")
Arguments
pkgname |
a string, the name of the package in which to look for the Stan code. |
Value
a list with the Stan code location within the package and the text of the code,
Examples
find_stan_code(pkgname = "staninside")
Create Package Infrastructure for Stan Package
Description
Create directory and helper files for a Stan package using CmdStanR
Usage
setup_stan_package(loc = NULL, use_all = TRUE)
Arguments
loc |
a file.path indicating package root. |
use_all |
a logical indicating if each section of Stan code
should have it's own directory with a default of |
Value
invisible null
Examples
# Create Temporary Directory
temp_dir <- tempdir()
# Now setup the structur
setup_stan_package(loc = temp_dir)
# Examine output
list.files(temp_dir, recursive = TRUE)