[R] Need help in calling C code from R

Dirk Eddelbuettel edd at debian.org
Sun Nov 16 17:43:06 CET 2008


On 16 November 2008 at 15:51, Prof Brian Ripley wrote:
| See the manual we wrote to help you, 'Writing R Extensions'.  If that is 
| not enough, the topic is covered in several books on R, including 'S 
| Programming'.  You can also find on-line tutorials of various qualities 
| (often obsolete or inaccurate).

That is a somewhat curious comment given that 'S Programming' -- a book I
absolutely loved when it came out, that I learned a lot from and that I still
like -- is also 'obsolete and inaccurate' given its eight years of age.  It
devotes under two pages to R package building, does not cover NAMESPACES, is
of course a number of revisions behind the current S4 standard etc pp.

I second the recommendation of 'Writing R Extension', but that is not the
most linear or coherent introduction. So despite the dire warning about
anything not authored by Prof Ripley, for an introduction to extending R via
C/C++ code, you may like the section in my UseR! 2008 tutorial on 'high
performances computing with R' that is available via

    http://dirk.eddelbuettel.com/presentations.html   

My preferred interface is Rcpp which IMHO eases interfacing C or C++ as you
can work more easily in native R types. Since the tutorial, I have formally
adopted Rcpp, reworked the installation and documentation, and made a new
release on CRAN -- see either one of

    http://dirk.eddelbuettel.com/code/rcpp.html
	 
    http://cran.r-project.org/web/packages/Rcpp/index.html

Hope this helps,  Dirk


| 
| On Sun, 16 Nov 2008, Rainer M Krug wrote:
| 
| > Hi
| >
| > I would like to implement the "Earth Movers Distance" into R and found
| > the code in C on the following page:
| >
| > http://www.cs.duke.edu/~tomasi/software/emd.htm
| >
| > Unfortunately, I don't know much (nearly nothing) about C and how to
| > call it from R.
| > As far as I have seen, the calling of the code from R should be rather
| > straight forward, but there are still several things I don't
| > understand.
| >
| > Could somebody please help me in calling the code from R?
| >
| > Thanks,
| >
| > Rainer
| >
| > P.S: if the code works nicely, I would like to either put it into a
| > package or add it to one.
| >
| > -- 
| > Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
| > Biology, UCT), Dipl. Phys. (Germany)
| >
| > Centre of Excellence for Invasion Biology
| > Faculty of Science
| > Natural Sciences Building
| > Private Bag X1
| > University of Stellenbosch
| > Matieland 7602
| > South Africa
| >
| > ______________________________________________
| > R-help at r-project.org mailing list
| > https://stat.ethz.ch/mailman/listinfo/r-help
| > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
| > and provide commented, minimal, self-contained, reproducible code.
| >
| 
| -- 
| Brian D. Ripley,                  ripley at stats.ox.ac.uk
| Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
| University of Oxford,             Tel:  +44 1865 272861 (self)
| 1 South Parks Road,                     +44 1865 272866 (PA)
| Oxford OX1 3TG, UK                Fax:  +44 1865 272595
| 
| ______________________________________________
| R-help at r-project.org mailing list
| https://stat.ethz.ch/mailman/listinfo/r-help
| PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
| and provide commented, minimal, self-contained, reproducible code.

-- 
Three out of two people have difficulties with fractions.



More information about the R-help mailing list