Comments (12)
This is a problem that should probably be fixed. Putting code in generated quantities block is very limiting.
from rstantools.
I'm having the same issue but deleting this block of code doesn't fix it. I used rstanstools::rstan_package_skeleton to setup a package and added the default timesTwo.cpp to the package. I'm getting the error
Error in timesTwo(rnorm(10)) : object '_test_timesTwo' not found
I'd like to have a package to fit a model using RStan and then use an RcppArmadillo function to post-process the data. I can't find any documentation referring to implementing stand-alone Rcpp functions within an RStan package. Any help would be appreciated.
from rstantools.
from rstantools.
I agree with above. I'm trying to make a package that includes simulations using Rcpp, and having those functions in generated quantities blocks instead of their own .cpp files is a real problem.
from rstantools.
I would also need RcppArmadillo to work in a package created using Rstantools. I have the same problem: object [name of function] not found
from rstantools.
I have successfully combined external C++ and Stan models in the same package in the past (https://github.com/helske/walker), but I just started to update some stuff and something has changed so that I new I get an infinite recompilation loops... And if I switch to newer package skeleton structure, I also face the issue that either Stan models or other C++ functions are not getting exported (depending on how I tweak Makevars etc).
from rstantools.
from rstantools.
Yes I just realized that as well, removing the roxygen line fixed the infinite loop issue and the package compiles. But the Stan models are not getting exported. Investigation continues...
edit: Oops, I had a wrong version of the stanmodels.R
file. Everything works now: https://github.com/helske/walker.
from rstantools.
from rstantools.
I encountered the same problem today, that I couldn't use Rcpp functions in a package generated with rstanstools::rstan_package_skeleton
.
I found that removing the R_init_mypackage
function fixes the problem of calling the Rcpp functions, because the function is then generated by Rcpp in RcppExports.cpp
. But I got another error when I loaded the package that "object 'm' not found" as described in issue #43.
I solved this issue by adding
// [[Rcpp::init]]
void rstan_additional_init(DllInfo *dll){
R_useDynamicSymbols(dll, TRUE); // necessary for .onLoad() to work
}
which makes sure that the dynamic symbol is accessible in the .onLoad
function in zzz.R.
So in conclusion, replacing the R_init_mypackage
function with the code above fixed my problem.
from rstantools.
from rstantools.
Just a quick comment to add to @const-ae, encountered the same issue and had some trouble getting it to work, in addition to @const-ae suggestion that were required. A few quick notes that would have helped me. You also need to include RcppExports.o and the other Rcpp source files in the sources variable of Makevars (and I assume Makevars.win but have not tested that)
I was also having troubles with including RcppArmadillo, it turns out I needed to import it before importing RcppEigen in the DESCRIPTION file.
from rstantools.
Related Issues (20)
- GHA failure of new standalone functions checks HOT 1
- Problem with line endings in automatically generated src/ files HOT 1
- Problems with compiling mixutre models on Windows (rstantools 2.3.0) HOT 4
- auto detect need for recompile? HOT 9
- Auto-format Stan models during rstan_config()? HOT 5
- Slow package building with rstan 2.26.23
- automatically exposing functions from Stan to R
- write_stan_json and to_stan_json to rstantools? HOT 6
- add posterior_epred generic
- include problem with some versions of rstantools 2.x and/or StanHeaders HOT 43
- errors if user model is called base.stan HOT 1
- Are ALL stan models recompiled when a package is updated? HOT 3
- LoadLibrary failure for Prophet on Windows HOT 11
- configure files in packages made with rstan_create_package() produces a note when running R CMD check HOT 3
- switch to github actions for CI
- don't create travis.yml
- Github actions workflow - test against rstan experimental or preview? HOT 2
- Backwards compatibility issue with model names HOT 1
- rstantools cannot find `stan/version.hpp` HOT 6
- R CMD check NOTE about Imports: RcppParallel HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rstantools.