Dirk Eddelbuettel — written Jan 3, 2013 — source
Extending R with C++ code by using Rcpp typically involves function
calls by leveraging the existing
.Call() interface of the R API.
Passing values back and forth is then done in manner similar to
programming with functions.
However, on occassion it is useful to access enviroments (such as
the global environment). We can also pass environments (which are
first-class datatypes for R) around to instantiate the Rcpp class
Here we illustrating how to access values from the global environment.
First, let us set some values:
We can access these values in a C++ function setup with Rcpp:
Running the example yields:
Stooge Nb 2 is: larry