C code and R
On Mon, 9 Jul 2001, Agustin Lobo wrote:
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 ?
Not specifically on R. You may find the book "S Programming" by Venables & Ripley useful.
2. Writing R Extensions starts dealing with C programs assuming that those have already been compiled: "Interface functions .C and .Fortran These two functions provide a standard interface to compiled code that has been linked into R,... " Are there any constraints that should be considered at compiling a function that is intended to be called by R?
Not really, if .C is being used to call it. It is a good idea to use R's facilities if you want to print to the screen from C code, and it may well help to use R's memory management (eg Calloc or R_alloc) rather than managing memory yourself, but these are optional. While you need to learn more initially it is often more effective to use the .Call() interface unless you need portability between S and R (and sometimes even then).
Splus (unix v 3.x) used to have an script (Splus COMPILE) to make sure that the compilation was done with the proper flags. Is there an equivalent R COMPILE script?
Section 4.4 of "Writing R Extensions" describes how you do this. -thomas Thomas Lumley Asst. Professor, Biostatistics tlumley at u.washington.edu University of Washington, Seattle -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._