[Rcpp-devel] Data Persistence when using inline

Dirk Eddelbuettel edd at debian.org
Wed Sep 7 23:56:46 CEST 2011

On 7 September 2011 at 14:46, Noah Silverman wrote:
| Hi,
| I'm writing a function using Rcpp through inline.  This function will be a
| filter on an incoming data stream.  
| I need to keep the past several data values so that they are accessible to the
| function each time it is called.   This is easy to do with a data structure in
| R (and then passing subsequent structure to the C++ function) but that seems
| rather slow.  Is there some way to define a persistent object that is
| accessible to an Inline function using Rcpp?
| If the code was in pure C++, it would be trivial to have an object and then
| just pass a pointer to that object.  I can't figure out how to do the same
| thing with R+Rcpp+inline.

i)   Read up on the 'static' argument for variable declarations in C and C++.

ii)  Rethink your architecture, maybe have an 'agent' operate on the stream
     and report to a persisting 'broker' that keeps state.

iii) Read up on persisting data as a general issue.

This has little to do with Rcpp and your preference of inline over packages,
but rather with how to think in code (and/or C++) and that is NOT a topic
covered on this list.  

Let's please try to keep focus on Rcpp and related questions here.


| Thanks!
| --
| Noah Silverman
| UCLA Department of Statistics
| 8117 Math Sciences Building #8208
| Los Angeles, CA 90095
| ----------------------------------------------------------------------
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Two new Rcpp master classes for R and C++ integration scheduled for 
New York (Sep 24) and San Francisco (Oct 8), more details are at

More information about the Rcpp-devel mailing list