[R-pkg-devel] Including Rcpp in an existing package

Glenn Schultz glennmschultz at me.com
Fri Dec 23 03:51:57 CET 2016


Hello All,

Thank-you all for your responses it was very helpful.  I have one last question.  I was planning on branching a new version of my package to allow the use of rcpp.  

My question is, Can I just set up my package to be rcpp ready (for lack of a better term) without testing C++ code in the request directories? Are there adverse consequences?  

I can see from the project I am working one that one may choose to implement certain processes (interest rate model or prepayment models) implemented in C++ code.  So I am beginning to think if the package is rcpp ready at the source it would make things easier for users seeking to customize those inputs in the future and build bespoke versions of the package or is this approach a bad idea?

Best,
Glenn 


On Dec 22, 2016, at 01:35 PM, Dirk Eddelbuettel <edd at debian.org> wrote:


On 22 December 2016 at 14:15, Duncan Murdoch wrote:
| On 22/12/2016 1:55 PM, Glenn Schultz wrote:
| > All,
| > My package was not initially built with the rcpp use in mind. I have to include C++ source code for a particular project so I will have edit the description file add src files, etc. by hand. I an going over the rcpp documentation now and reviewing the R documentation on extensions as well. Is there anything in particular that I should keep in mind while doing this or is this relatively straightforward.
| 
| It should be pretty straightforward. There are lots of examples of 
| packages that do it (not all of which are simple); see the list of 
| "reverse XXXX" on https://CRAN.R-project.org/package=Rcpp (where XXXX is 
| Depends, Imports, Suggests, or LinkingTo).

Exactly. I also (still) hand-edit a chronological list at

http://dirk.eddelbuettel.com/code/rcpp.cranusers.html

which contains a mix of 'fresh packages' (starting from scratch with Rcpp)
and 'converted packages' (which is what you are after). Sadly the latter set
is not indexed, so you have 'know' when a packages was pre-existing when it
made the list.

On 22 December 2016 at 14:22, Ben Bolker wrote:
| 
| A mistake that I have made repeatedly is forgetting to add an
| appropriate UseDynLib() call to the NAMESPACE file.

Exactly, as well (though really an issue about going from no src/ to having
src).

For the issue here I recommend creating two _minimal_ packages via, say,

setwd("/tmp") # alter as neded
package.skeleton("fooR")
Rcpp.package.skeleton("fooRcpp")

and the study where/how they differ. And maybe try to convert fooR into
fooRwithRcpp.

There is a dedicated list for Rcpp questions too.

Dirk

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


More information about the R-package-devel mailing list