[R] C code and R

Duncan Murdoch murdoch at stats.uwo.ca
Mon Jul 9 17:17:50 CEST 2001


On Mon, 9 Jul 2001 15:50:16 +0200 (MET DST), you wrote in message
<Pine.OSF.3.96.1010709154519.2609J-100000 at ija.csic.es>:

>
>A couple of questions on calling C programs
>from R functions:
>
>1. Is there any other guide on this matter in addition to
>Writing R Extensions ?

I don't think there is anything written as a guide, but the source to
lots of packages is available on http://cran.r-project.org.  I'd
suggest getting a copy of a small one of those (e.g. Rstreams has C
source, you'll have to look yourself for a small one with Fortran
source), and just modify all the files to suit your needs.  If you put
the files in 

  ${RHOME}/src/library/yourpackage

and have all the recommended tools and paths set up properly, then

  make pkg-yourpackage

will compile and install the package, so that

  library(yourpackage)

will work in R.

You don't need to put it in a package (you can just compile and link
and use dyn.load() instead of library), but packages are very
convenient because of all the support in the makefiles.  I imagine the
makefiles have targets defined for doing this, but I don't think they
are documented anywhere other than in the makefiles themselves, and
those are pretty complicated.


Duncan Murdoch
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list