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

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

tech