use_tmb | R Documentation |
Add TMB functionality to an existing package.
use_tmb()
Adds the following to the package:
src/TMB/compile.R
: runs the C++ compiler on TMB model files (see export_models
).
src/Makevars[.win]
: ensures that TMB compilation does not affect that of other source files in src
.
src/init_dummy_file.cpp
: needed to set R_registerRoutines
if the package contains no other source code apart from what's in src/TMB
.
Imports: TMB
and LinkingTo: TMB
are added to the package's DESCRIPTION
.
An optional file R/pkgname-package.R
with roxygen2 NAMESPACE
directives, if such a file does not exist. Otherwise, prints instructions as to how the NAMESPACE
must be modified (see below).
Because of how TMB source files are compiled, at present the package must create two shared object (.so
, .dll
) files: pkgname_TMBExports.so
for the TMB models, and pkgname.so
for the usual package source code. In the NAMESPACE
file, it is imperative that the latter be 'useDynLib'ed before the former. The fail-safe roxygen2 instruction for this is
#' @rawNamespace useDynLib(pkgname, .registration = TRUE); useDynLib(pkgname_TMBExports)
Nothing; called for its side effects.
export_models
for details on adding TMB model files after running use_tmb
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.