[R] How to use the .C() function? How to load the code?

Raphael Gottardo raph at alvie-mail.lanl.gov
Sat Jul 21 02:11:37 CEST 2001


Hello R-users,

I have a question about the .C() function in R to call a C function. I
would like to know how to load the compiled code into R (if this is what
I need to do) . Iam not an expert in R neither in C. So the online help
was pretty much chinese for me.
I use R under linux, I use gcc to compile my code:

Let's take a very simple example:
double  addition(double a,double b)
{

  double c;
  c=a+b;

  return(c);

}

then under R I use
addition_function(a,b)
{
.C("addition",as.double(a),as.double(b))
}

But obviously it does not work since I haven't loaded or compiled
anything under R
.> addition(2,3)
Error in .C("addition", as.double(a), as.double(b)) :
        C/Fortran function name not in load table


I would really appreciate some help or some easy reading references.


Thank you very much,

Raphael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: raph.vcf
Type: text/x-vcard
Size: 312 bytes
Desc: Card for Raphael Gottardo
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20010720/f3489392/raph.vcf


More information about the R-help mailing list