[Rcpp-devel] Internals: how does DataFrame get initialized?

Darren Cook darren at dcook.org
Wed Feb 29 06:51:58 CET 2012


> It also includes "DataFrame_generated.h", which contains
> automatically generated constructors with 1 to X (currently X=20)
> "Named" arguments.

Thanks. (your URL didn't give me permission, but I found it on my
machine in /usr/local/lib/R/site-library/Rcpp/include/Rcpp )

It does:
  return DataFrame(
    internal::try_catch(
      ::Rcpp_lcons(
        ::Rf_install( "data.frame"),
        pairlist( t1, t2, t3, t4, t5 )
  )));

pairlist() appears to initialize a PairList object, which is a
DottedPair object. (It derives from PairList, but does not seem to add
anything?)

DottedPair derives from RObject, but adds, er, functions. (Which Rcpp
functionality is this adding? Why are these functions in their own class
and not in RObject?)

Finally RObject is the class that holds the SEXP.
Last must-be-easy question of this email: where is RObject.cpp? Where is
the RObject::setSEXP() function body?

Thanks,
Darren


>> I wanted to understand what this code [1] actually does:
>>
>> std::vector<double> vt, vpx, vsz;
>> std::vector<std::string> vsrc, vtype;
>> ...
>> Rcpp::DataFrame df = Rcpp::DataFrame::create(
>>    Rcpp::Named("t", vt),
>>    Rcpp::Named("type", vtype),
>>    Rcpp::Named("src", vsrc),
>>    Rcpp::Named("px", vpx),
>>    Rcpp::Named("sz", vsz)
>>    );
>>
>> Rcpp::Named(x,y) was easy [2]: it makes a little object that just stores
>> references to the two variables.
>>
>> Understanding Rcpp::DataFrame::create() was harder [3], with 5
>> constructors, none of which seem like they would do the job. Can someone
>> give me a pointer to what I should study next.
>>
>> TIA,
>>
>> Darren
>>
>>
>> [1]: Extracted from:
>>
>> http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-January/003345.html
>>
>>
>> [2]:
>> http://dirk.eddelbuettel.com/code/rcpp/html/Named_8h_source.html
>> http://dirk.eddelbuettel.com/code/rcpp/html/named__object_8h_source.html
>>
>> [3]:
>> http://dirk.eddelbuettel.com/code/rcpp/html/DataFrame_8h_source.html
>>
>> -- 
>> Darren Cook, Software Researcher/Developer
>>
>> http://dcook.org/work/ (About me and my work)
>> http://dcook.org/blogs.html (My blogs and articles)
>> _______________________________________________
>> 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
>>
> 


-- 
Darren Cook, Software Researcher/Developer

http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)


More information about the Rcpp-devel mailing list