[Rcpp-devel] Basic documentation for Rcpp
edd at debian.org
Fri May 13 15:45:04 CEST 2011
On 13 May 2011 at 15:02, Nick Sabbe wrote:
| Hello all.
| Today, I posted a question on stackoverflow.com, but I was advised to ask the
| question through this mailing list.
That is indeed frequently suggested by Romain and myself, and I am glad that
others suggested it to you to. With that, thanks for posting here.
| So, here is the verbatim question from SO (http://stackoverflow.com/questions/
I took a few minutes and quickly edited a reply over there. I will repost it
here later if nobody beats me to answering your questions. Below are just
some additional real quick answer.
I really suggest that you make an effort of re-reading Rcpp-introduction
which answers some of the questions below.,
| I want to look into rcpp to improve the speed of some of my R code without
| having to resort to messy C++ code (I've had some success with that, but it
| looks like code from hell).
| So, I checked the documentation provided with Rcpp, and also the bundle of
| documents provided at Dirk Eddelbuettel's site. I installed and looked at
| RcppExamples, but (at least from its documentation) most of these refer to
| RcppClassic?. Besides that, I did some googling but that didn't result in
| answers to what seem like basic questions.
| ? Do indexes in Rcpp work zero-based or one-based
Zero-based as are all C and C++ programs (unless you do something crazy and
redefine things). We do not attempt to change C++.
| ? List provides both operator() and operator, but apparently
| not operator[]. It is not clear which ones are similar to  and [] in R.
There cannot be. We are bound by what C++ lets us do. Likewise there is no
matrix indexing M[i][j] -- it has to be M(i,j).
| ? Is there any support for factors in Rcpp (there does not appear to be
It is on the TODO list but low priority for us. Export the factor levels as
character, and the factor values via as.integer. Contributions of a
Rcpp::Factor class would welcome.
| Note: in fact I found some answers from the first example in
| Rcpp-introduction.pdf, but that just felt like luck.
| Also, my stl is very rusty, so if anybody can provide me with a simple example
| where each element of a List is (e.g.) print-ed with an stl-style loop, that
| would be neat.
| If anybody wants to call me an idiot for not finding this information: go ahead
| and make your day. Then make mine and point me to the docs I need :-)
| As a suggestions to Mr. Eddelbuettel and other Rcpp authors (I expect some of
| them to read this): the class hierarchies and the like, provided by doxygen,
| are really neat when you are already kneedeep into Rcpp, but for a beginner (in
| Rcpp), I am more interested in a list of 'this method in this class does this
| like that function in R' rather than 'you can find the declaration of this
| operator in this header file'. After all, I understand one of the goals of Rcpp
| is to lower the threshold for using C++ in R? Note: from what I have seen and
| understood, I highly value the actual code of Rcpp and have the highest respect
| for its creators. If the lack of basic documentation is merely a result of
| 'lack of resources', I would be willing to become a resource (e.g.: work on
| 'basic' documentation once I get through it myself).
| Nick Sabbe
| ping: nick.sabbe at ugent.be
| link: http://biomath.ugent.be
| wink: A1.056, Coupure Links 653, 9000 Gent
| ring: 09/264.59.36
| -- Do Not Disapprove
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
Gauss once played himself in a zero-sum game and won $50.
-- #11 at http://www.gaussfacts.com
More information about the Rcpp-devel