Using simcdm in R packages

James Joseph Balamuta


Package usage

The design of simcdm allows the package to be included in other R packages using either the R or C++ functions. The next section details provides with how to incorporate either the R or C++ functions into a new R package or standalone C++ file.

Note, if you are not familiar with compiled code in R please feel free to use the traditional way to import the R functions.

R Package Usage

To use simcdm’s R functions only in your own R package, modify the package’s DESCRIPTION file by adding an imports declaration.

Inside of the package’s NAMESPACE file, make sure to use:

If you are using roxygen2 to manage the packages NAMESPACE file, add the following tag and re-run the roxygenize() function.

C++ Usage

C++ Package

To use C++ functions available in simcdm within your R package, modify your package’s DESCRIPTION file by adding:

LinkingTo: Rcpp, RcppArmadillo (>= 0.9.200), simcdm
    Rcpp (>= 1.0.0)

Reference the simulation functions using simcdm namespace like so: