rcpp
RcppArmadillo pass user-defined function
(Sometime you need to use svn log … on files to see how dated they are…) I think a better use case is in my “port” of the C-based DEoptim to Rcpp / RcppArmadillo: RcppDE. In it, I allow the optimization routine to use either an R function (as DEoptim does) or a user-supplied compiled … Read more
Cannot compile R packages with c++ code after updating to macOS Catalina
You likely need to reinstall command line tools — Apple often uninstalls them after OS updates. Try running: xcode-select –install in the terminal. (Note that, even if you’re using the R-provided LLVM toolchain, it will still require access to the default system headers, and those are installed as part of the command line tools toolchain) … Read more
Understanding the contents of the Makevars file in R (macros, variables, ~/.R/Makevars and pkg/src/Makevars)
The Makevars file, as specified in Writing R Extensions: 1.2.1 Using Makevars, is a variant of Make that is unique to R. Many of the variables you have listed are called implicit variables. The meaning is given as: Implicit rules tell make how to use customary techniques so that you do not have to specify … Read more
Replace negative values by zero
Thanks for the reproducible example. This is pretty basic R stuff. You can assign to selected elements of a vector (note an array has dimensions, and what you’ve given is a vector not an array): > pred_precipitation[pred_precipitation<0] <- 0 > pred_precipitation [1] 1.2091281 0.0000000 7.7665555 0.0000000 0.0000000 0.0000000 0.5151504 0.0000000 1.8281251 [10] 0.5098688 2.8370263 0.4895606 … Read more
Using Rcpp within parallel code via snow to make a cluster
Think it through — what does inline do? It creates a C/C++ function for you, then compiles and links it into a dynamically-loadable shared library. Where does that one sit? In R’s temp directory. So you tried the right thing by shipping the R frontend calling that shared library to the other process (which has … Read more