Skip to content

Random tips and tricks

Daniel Turek edited this page Jun 23, 2022 · 28 revisions
  • To check that a C++ compiler installed:
devtools::has_devel()
  • To see the internal adaptation info from adaptive samplers:
nimbleOptions(buildInterfacesForCompiledNestedNimbleFunctions=TRUE)
Cmcmc$samplerFunctions$contentsList[[i]]$propCov
  • To build & install developmental version from github:
remove.packages('nimble')
library(remotes)
remotes::install_github('nimble-dev/nimble', ref = 'devel', subdir = 'packages/nimble')
library(nimble)
  • Get samplesPlot() and chainsPlot() MCMC plotting functions:
library(basicMCMCplots)
  • When package build fails around release, possibly with error library not found for -lgfortran, in src/Makevars.in, comment out FLIBS to read: #$(FLIBS)

  • To clear all loaded DLLs w.r.t. any project (pass any object from that project):

nimble:::clearCompiled(Rmodel)
  • Access / assign to a variable in a nested compiled nimbleFunction (without using the option nimbleOptions(buildInterfacesForCompiledNestedNimbleFunctions = TRUE)):
valueInCompiledNimbleFunction(outerNF$nestedNF, 'x')
valueInCompiledNimbleFunction(outerNF$nestedNF, 'x', newValue)
valueInCompiledNimbleFunction(Cmcmc$samplerFunctions[[i]], 'x')
valueInCompiledNimbleFunction(Cmcmc$samplerFunctions[[i]], 'x', newValue)
  • Dig one level deeper into compiled objects, e.g., access an internal state variable, from within a nested compiled nimbleFunction:
valueInCompiledNimbleFunction(Rmcmc$samplerFunctions$contentsList[[1]]$my_calcAdaptationFactor$.CobjectInterface, 'gamma1')
valueInCompiledNimbleFunction(Cmcmc$Robject$samplerFunctions$contentsList[[1]]$my_calcAdaptationFactor$.CobjectInterface, 'gamma1')
  • Get ancestors (parents) of a model node:
md <- model$getModelDef()
parentIDs <- md$maps$edgesFrom[ md$maps$edgesTo == md$nodeName2GraphIDs(node) ]
parentNodes <- md$maps$graphID_2_nodeName[ parentIDs ]
  • Fixing Windows compilation error: In system(cmd) : 'make' not found
currentPath <- Sys.getenv('PATH')
newPath <- paste0('C:\\Rtools\\bin;C:\\Rtools\\mingw_64\\bin;', currentPath)
Sys.setenv(PATH = newPath)
vignette('Introduction_to_nimbleEcology', package = 'nimbleEcology')
  • Debugging generated C++ code:
nimbleOptions(debugCppLineByLine = TRUE)
  • Issues using install_github, in particular:
install_github("nimble-dev/nimble", ref = "devel", subdir = "packages/nimble")
## The R package directory has not been created yet
## ** libs
## Error: (converted from warning) this package has a non-empty 'configure.win' file, so building only the main architecture
- Get `samplesPlot()` and `chainsPlot()` MCMC plotting functions:

In this case, try (1) in R execute the line Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS = "true"), and then run the install_github, and (2) add INSTALL_opts="--no-multiarch" as an argument to install_github.

Clone this wiki locally