Rcpp (version 1.0.8)

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


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.


Rcpp.package.skeleton(name = "anRpackage", list = character(), 
	environment = .GlobalEnv, path = ".", force = FALSE, 
	code_files = character(), cpp_files = character(),
	example_code = TRUE, attributes = TRUE, module = FALSE, 
	author = "Your Name", 
	maintainer = if(missing( author)) "Your Name" else author, 
	email = "your@email.com", 
	license = "GPL (>= 2)"



A character vector with the paths to C++ source files to add to the package.


If TRUE, example c++ code using Rcpp is added to the package.


If TRUE, example code makes use of Rcpp attributes.


If TRUE, an example Module is added to the skeleton.


Author of the package.


Maintainer of the package.


Email of the package maintainer.


License of the package.


Nothing, used for its side effects


In addition to package.skeleton :

The DESCRIPTION file gains an Imports line requesting that the package depends on Rcpp and a LinkingTo line so that the package finds Rcpp header files.

The NAMESPACE gains a useDynLib directive as well as an importFrom(Rcpp, evalCpp to ensure instantiation of Rcpp.

The src directory is created if it does not exists.

If cpp_files are provided then they will be copied to the src directory.

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 attributes argument is TRUE, then rather than generate the example files as described above, a single rcpp_hello_world.cpp file is created in the src directory and it's attributes are compiled using the compileAttributes function. This leads to the files RcppExports.R and RcppExports.cpp being generated. They are automatically regenerated from scratch each time compileAttributes is called. Therefore, one should not modify by hand either of the RcppExports files.

If the module argument is TRUE, a sample Rcpp module will be generated as well.


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



# simple package
Rcpp.package.skeleton( "foobar" )

# package using attributes
Rcpp.package.skeleton( "foobar", attributes = TRUE )

# 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" )

# }