Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

compileAttributes

Compile Rcpp Attributes for a Package


Description

Scan the source files within a package for attributes and generate code as required. Generates the bindings required to call C++ functions from R for functions adorned with the Rcpp::export attribute.

Usage

compileAttributes(pkgdir = ".", verbose = getOption("verbose"))

Arguments

pkgdir

Directory containing the package to compile attributes for (defaults to the current working directory).

verbose

TRUE to print detailed information about generated code to the console.

Details

The source files in the package directory given by pkgdir are scanned for attributes and code is generated as required based on the attributes.

For C++ functions adorned with the Rcpp::export attribute, the C++ and R source code required to bind to the function from R is generated and added (respectively) to src/RcppExports.cpp or R/RcppExports.R. Both of these files are automatically generated from scratch each time compiledAttributes is run.

In order to access the declarations for custom Rcpp::as and Rcpp::wrap handlers the compileAttributes function will also call any inline plugins available for packages listed in the LinkingTo field of the DESCRIPTION file.

Value

Returns (invisibly) a character vector with the paths to any files that were updated as a result of the call.

Note

The compileAttributes function deals only with exporting C++ functions to R. If you want the functions to additionally be publicly available from your package's namespace another step may be required. Specifically, if your package NAMESPACE file does not use a pattern to export functions then you should add an explicit entry to NAMESPACE for each R function you want publicly available.

In addition to exporting R bindings for C++ functions, the compileAttributes function can also generate a direct C++ interface to the functions using the Rcpp::interfaces attribute.

See Also

Examples

## Not run: 

# Compile attributes for package in the current working dir
compileAttributes()

## End(Not run)

Rcpp

Seamless R and C++ Integration

v1.0.6
GPL (>= 2)
Authors
Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey, Qiang Kou, Nathan Russell, Douglas Bates and John Chambers
Initial release
2021-01-14

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.