Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where is a good tutorial on creating an R package with C++ source code? [closed]

I'm at a loss when I start looking at configure scripts. I'm not sure how to go about creating an R package which has several functions built from C/C++ in such a way that it's portable between Windows & Linux. My attempts to modify the guts of existing packages have been unfruitful.

Any help or links would be greatly appreciated.

Update: If possible I would like to link against: Boost, CUDA, & hwloc

However, I realize that Boost will be a nightmare & hwloc won't be much better. So I'd settle for just CUDA. This was why I dove in the deep end and tried modifying some existing packages to suit my needs (rgl & rglpk). But I'm willing to start out without dependencies and build from the ground up. Thank you everyone for your suggestions!!

like image 635
M. Tibbits Avatar asked Mar 02 '11 18:03

M. Tibbits


1 Answers

I was also quite lost when writing my first package with compiled code. Here are a few tips, but there is probably better material out there.

The main piece about writing R packages is "Writing R extensions". This is a very complete guide, but that also makes it abit hard to read through: http://cran.r-project.org/doc/manuals/R-exts.pdf

Here is a small tutorial I found on google once which I used first, containing how to use C code: http://www.stat.columbia.edu/~gelman/stuff_for_blog/AlanRPackageTutorial.pdf

Another guide on R packages in general, but not with C code: http://cran.r-project.org/doc/contrib/Leisch-CreatingPackages.pdf

Rcpp is a very useful package for C++ code, but I haven't used it a lot yet (3 days in fact). It has a lot of documentation in the package itself.

like image 130
Sacha Epskamp Avatar answered Oct 03 '22 02:10

Sacha Epskamp