[Rcpp-devel] Using data-frames as sets of rows (e.g. using R data-frames as lookup tables in C++)

Dirk Eddelbuettel edd at debian.org
Fri Sep 6 16:33:43 CEST 2013


On 6 September 2013 at 14:20, Mark Clements wrote:
| By my understanding, Rcpp is better suited to working with data-frames as
| columns rather than working with data-frames as a set of rows. However,
| occasionally it may be useful to work with the set of rows. How have others
| considered this use case?

This has been discussed a few times here.  The upshot is that Rcpp offers
"proxy classes" as very thin and efficient shims over the internal R
representation.  Which is a __list of vectors__ for a data frame.  So columns
it is, because that is what we get from R / what R expects from us.

Romain has opened a mad-scientist lab over at 

   https://github.com/romainfrancois/RcppExtras 

where he is playing with a few things.  Which may or may not end up here,
which may or may not work now or in the future, and which may set your hair
on fire. It's a lab to try things.
 
| [As a motivating example based on simulations in C++, we want to pass
| data-frames from R for use as look-up tables in C++ (cf. passing transformed
| data back to R). The STL container std::map is well suited to this task,
| particularly as it provides ordered keys.

[ ... snip ... ]

All good, and I am very much in favour of creating useful abstractions on top
of the interface.  

But for better or worse, "eventually" everything has be a SEXP to go back to
R so we may need a tranpose somewhere.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list