README (original) (raw)

tidyCpp: Tidy C++ wrapping of the C API for R

CI License CRAN Dependencies Downloads Last Commit

About

The C API of the R language and environment is robust, yet a little awkward for C++ programmers. This package wraps a tidy layer of header functions around it.

Examples

A recent motivating example is from the dang package which includes one unexported Base R function written in C. The original version is here. While short enough, we found working with a tidier version easier and more enjoyable. We include an abbreviated version (minus the copyright header) here:

Additions from the tidyCpp wrapper can be identified easily via the R:: namespace. While the code is not hiding its C heritage, we find it overall a little easier to work with. Other examples (see below) show how using tidyCpp can help avoid the very manual and error-prone PROTECT and UNPROTECT and pairs.

For additional examples, please see the Motivation vignette for a longer discussion with more examples, and the files in the snippets/ directory for directly callable code examples.

Dirk Eddelbuettel

License

GPL (>= 2)