Learn R Programming

Rcpp (version 0.9.15)

Rcpp.package.skeleton: Create a skeleton for a new package depending on Rcpp

Description

Rcpp.package.skeleton automates the creation of a new source package that intends to use features of Rcpp. It is based on the package.skeleton function which it executes first.

Usage

Rcpp.package.skeleton(name = "anRpackage", list = character(), 
	environment = .GlobalEnv, path = ".", force = FALSE, 
	namespace = TRUE, code_files = character(), 
	example_code = TRUE, module = FALSE, 
	author = "Who wrote it", 
	maintainer = if(missing( author)) "Who to complain to" else author, 
	email = "yourfault@somewhere.net", 
	license = "What Licence is it under ?"
	)

Arguments

environment
namespace
code_files
example_code
If TRUE, example c++ code using Rcpp is added to the package.
module
If TRUE, an example Module is added to the skeleton.
author
Author of the package.
maintainer
Maintainer of the package.
email
Email of the package maintainer.
license
License of the package.

Value

  • Nothing, used for its side effects

Details

In addition to package.skeleton : The DESCRIPTION file gains a Depends line requesting that the package depends on Rcpp and a LinkingTo line so that the package finds Rcpp header files. The NAMESPACE, if any, gains a useDynLib directive. The src directory is created if it does not exists and a Makevars file is added setting the environment variables PKG_LIBS to accomodate the necessary flags to link with the Rcpp library. If the example_code argument is set to TRUE, example files rcpp_hello_world.h and rcpp_hello_world.cpp are also created in the src. An R file rcpp_hello_world.R is expanded in the R directory, the rcpp_hello_world function defined in this files makes use of the C++ function rcpp_hello_world defined in the C++ file. These files are given as an example and should eventually by removed from the generated package. If the module argument is TRUE, a sample Rcpp module will be generated as well.

References

Read the Writing R Extensions manual for more details.

Once you have created a source package you need to install it: see the R Installation and Administration manual, INSTALL and install.packages.

See Also

package.skeleton

Examples

Run this code
# simple package
Rcpp.package.skeleton( "foobar" )

# package with a module
Rcpp.package.skeleton( "testmod", module = TRUE )

# the Rcpp-package vignette
vignette( "Rcpp-package" )

# the Rcpp-modules vignette for information about modules
vignette( "Rcpp-modules" )

Run the code above in your browser using DataLab