[Rcpp-devel] Returning a named (and classed?) list from an RcppExport SEXP function
Douglas Bates
bates at stat.wisc.edu
Fri Mar 12 17:14:44 CET 2010
I have looked at your (i.e. Dirk and Roman's) submitted Rjournal
article on Rcpp and decided that I should take the plunge.
To get my feet wet I am starting with a relatively simple example
interfacing to (God help us) 1960's style Fortran written by Mike
Powell and incorporated in the minqa package.
The value to be returned is a named list of heterogeneous values. I
can see how to construct such a list in the classic Rcpp API using a
RcppResultSet object but I don't know the best way to accomplish this
in the more modern Rcpp namespace. Can someone point me in the right
direction? Also, is there a convenient idiom for attaching an S3
class name to a list to be returned?
An unrelated question -- has anyone looked at accessing S4 classed
objects in Rcpp? I have had considerable experience with S4 classes
and objects and could keep such a project in mind as I begin to
explore Rcpp.
Yet another question, if i may. Does coercion take place in
constructing an object like
Rcpp::NumericVector aa(a);
where a is an SEXP, say an SEXP argument to a C++ function, where I
accidentally passed an integer vector instead of a double vector? If
so, what happens if there is no coercion? Are the contents of the
SEXP copied to newly allocated storage or not?
The reason that I ask is because there are some places in the lme4
code where I want to make sure that I have a pointer to the contents
of the original vector because I am want to change the contents
without copying.
More information about the Rcpp-devel
mailing list