Adding functions to existing package using rstantools

I’ve read through the rstantools step by step vignette and I think I understand how to add functions to a package I am creating using rstantools. I’ve also looked through the help file for rstan_create_package() as suggested in the vignette.

As I’m building my package, I sometimes have trouble adding Stan models to the package (i.e., the model does not get added to mypacackage:::stanmodels$new). I think I’ve figured out the steps through trial and error. The steps are as follows, correct?

  1. Add new stan file, e.g., inst/stan/new.stan
  2. Run rstantools::use_rstan()
  3. Run pkgbuild:: compile_dll () because I’m using devtools.
  4. Run roxygen2::roxygenize() to update the documentation
  5. Run devtools::install()

If these steps are correct, I will be happy to fork the step by step on GitHub and add this tutorial for adding a second function.

I would have guessed you could skip step (2), but maybe I am wrong.

@bgoodri thank you. I think I understand the rstantools package better. If I had an existing package without any RStan models, then I would use rstantools::use_rstan() , correct?

Also, I created a pulll request on GitHub for the vignette.:

Yeah exactly.

Awesome, thanks!

1 Like