Package: cpp4r 1.3.0

cpp4r: Header-Only 'C++' and 'R' Interface

Provides a header only, 'C++' interface to 'R' with enhancements over 'cpp11'. Enforces copy-on-write semantics consistent with 'R' behavior. Offers native support for ALTREP objects, 'UTF-8' string handling, modern 'C++' features and idioms, and reduced memory requirements. Allows for vendoring, making it useful for restricted environments. Compared to 'cpp11', it adds support for converting 'C++' maps to 'R' lists, 'Roxygen' documentation directly in 'C++' code, proper handling of matrix attributes, support for nullable external pointers, bidirectional copy of complex number types, flexibility in type conversions, use of nullable pointers, and various performance optimizations.

Authors:Mauricio Vargas Sepulveda [aut, cre], Posit Software, PBC [aut]

cpp4r_1.3.0.tar.gz
cpp4r_1.3.0.zip(r-4.7-any)cpp4r_1.3.0.zip(r-4.6-any)cpp4r_1.3.0.zip(r-4.5-any)
cpp4r_1.3.0.tgz(r-4.6-any)cpp4r_1.3.0.tgz(r-4.5-any)
cpp4r_1.3.0.tar.gz(r-4.7-any)cpp4r_1.3.0.tar.gz(r-4.6-any)
cpp4r_1.3.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
cpp4r/json (API)

# Install 'cpp4r' in R:
install.packages('cpp4r', repos = c('https://pachadotdev.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/pachadotdev/cpp4r/issues

On CRAN:

Conda:

cpp

8.84 score 8 stars 25 packages 3 scripts 2.2k downloads 4 exports 0 dependencies

Last updated from:7a375e1d84. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK115
source / vignettesOK162
linux-releaseOK112
macos-releaseOK94
macos-oldrelOK94
windows-develOK71
windows-releaseOK87
windows-oldrelOK93
wasm-releaseOK94

Exports:pkg_templateregisterunvendorvendor

Dependencies:

01 - Introduction
Motivation | Differences between R's C API and cpp4r | Memory protection | Creating vectors | Type checking and coercion | Strings | Missing values (NA) | Error handling | Lists | Calling R functions from C++ | Environments | External pointers | Matrices | Summary | References

Last update: 2026-07-27
Started: 2026-07-27

02 - Setup
C++ Setup | For Ubuntu Users | R Setup

Last update: 2026-07-27
Started: 2026-07-27

03 - Package Skeleton
Loading the Required R Packages | Creating a Dummy Package | Print a Number | Exporting a Registered Function | Number's Sign | Installing the Package | Good Practice | References

Last update: 2026-07-27
Started: 2026-07-27

04 - Read-only versus Writable R Objects
Read and write | References

Last update: 2026-07-27
Started: 2026-07-27

05 - Logical Functions
Notes | Is any value in a vector 'true'? | Which elements in a vector are 'true'? | Are all values in a vector 'true'? | References

Last update: 2026-07-27
Started: 2026-07-27

06 - Rolling Functions
Notes | Cumulative sum | Cumulative product | Range of values | References

Last update: 2026-07-27
Started: 2026-07-27

07 - Statistical Functions
Notes | Sum | Arithmetic mean | Variance | Root Mean Square Error (RMSE) | References

Last update: 2026-07-27
Started: 2026-07-27

08 - Logical Functions with Missing Values
Notes | Is any value in a vector 'true'? | Which elements in a vector are 'true'? | Are all values in a vector 'true'?

Last update: 2026-07-27
Started: 2026-07-27

09 - Rolling Functions with Missing Values
Notes | Cumulative sum | Cumulative product | Cumulative minimum | Cumulative maximum

Last update: 2026-07-27
Started: 2026-07-27

10 - Statistical Functions with Missing Values
Notes | Sum | Arithmetic mean | Variance | Root Mean Square Error (RMSE)

Last update: 2026-07-27
Started: 2026-07-27

11 - Debugging R Packages
Motivation | Compiler Setup | Testing for Memory Leaks | Adding a configure script | Testing with Docker | References

Last update: 2026-07-27
Started: 2026-07-27

12 - External Pointers

Last update: 2026-07-27
Started: 2026-07-27

13 - Compiler Optimizations
Motivation | User-wide Makevars | Anticonf scripts

Last update: 2026-07-27
Started: 2026-07-27

14 - Linear Algebra
Motivation | Using Armadillo | References

Last update: 2026-07-27
Started: 2026-07-27

15 - Internals
Initial setup and dev workflow | Code formatting | Code organization | Naming conventions | Vector classes | Coercion functions | Protection | Protect list | Unwind Protect

Last update: 2026-07-27
Started: 2026-07-27

16 - Worked Examples
Motivation | Instructional examples | Solving a matrix using the Gauss-Jordan method | Details | Vendoring | Building and testing | Ordinary Least Squares (OLS) estimator | Linear programming (Simplex phase 2) | Algorithm | Numerical example | Using OMP (parallelization) | Enabling OpenMP | Unnamed list | Named list | Implementing a rejection and bootstrap sampler | Extensive R/C++ tests | Useful R/C++ Integration Examples | References

Last update: 2026-07-27
Started: 2026-07-27

17 - FAQs
Is this only compatible with C++11? | Can I specify which C++ standard to use? | My laptop uses C++NN but my cluster uses C++MM, how can I make sure my code works on both? | What are the underlying types of cpp4r objects? | How do I add elements to a list? | Does cpp4r support default arguments? | How do I create a new empty list? | How do I retrieve (named) elements from a named vector/list? | How can I tell whether a vector is named? | How do I return a "cpp4r::writable::logicals" object with only a "FALSE" value? | How do I create a new empty environment? | How do I assign and retrieve values in an environment? What happens if I try to get a value that does not exist? | How can I create a "cpp4r:raws" from a "std::string"? | How can I create a "std::string" from a "cpp4r::writable::string"? | What are the types for C++ iterators? | What's wrong with "using namespace std"? | How do I modify a vector in place? | Should I call "unwind_protect" manually? | Destructors | Nested unwind_protect() | How do I modify a matrix rownames/colnames on C++ side? | How do I use the same seed defined in R for random number generation in C++? | How different is cpp11::function compared to cpp4r::function?

Last update: 2026-07-27
Started: 2026-07-27