Adding .stan/.R functions

Hello all,

Novice developer with limited C++ experience here. I have an already functioning rstan based package (very simple, one R function depending on one stan file). I want to add a second R function depending on a second stan file. I have and everything appears to be fine. I already had a .hpp file in /src/stan_files that shares the the name of the first R and stan file pairing (called lmem.R, lmem.stan, and lmem.hpp). I assume this .hpp file was automatically generated by usiing rstan_package_skeleton().

Now that I’m adding LSNM.R and LSNM.stan files do I also need to add a LSNM.hpp file into /src/stan_files? How should I go about doing that? What does the original lmem.hpp file do and how was it added? The GitHub link is below:

Thank you for your time

The foo.hpp file was generated when you did R CMD INSTALL.

You do need to put foo.stan into src/stan_files and then go into src/Makevars and src/Makevars.win and add foo.stan to the line that starts with SOURCES. After that, it should be fine.

Actually, you should just change the line that starts with SOURCES to

SOURCES = $(wildcard stan_files/*.stan)

and add

SystemRequirements: GNU make

to the DESCRIPTION file. That way, it will work automatically no matter how many Stan programs you ultimately add.

But I do not need to add a .hpp file into src/stan_files or change the one that’s currently there? Changing the SOURCES line and adding SystemRequirements to DESCRIPTION is sufficient?

Yes

Hello, so sorry for asking repeatedly. Moved my work my personal github (linked below) and now I’m experiencing an error when trying to download the package off of github that some light googling says might be related to Makevars and Makevars.win.
https://github.com/jacobjaf/polnet

The error message I get when i try to use devtools::install_github(“jacobjaf/polnet”) is:

Error: package or namespace load failed for ‘polnet’ in library.dynam(lib, package, package.lib):
DLL ‘LSNM’ not found: maybe not installed for this architecture?

Thanks for any possible help