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

About this list Date view Thread view Subject view Author view Attachment view

From: Raphael Gottardo (raph@alvie-mail.lanl.gov)
Date: Sat 21 Jul 2001 - 10:11:37 EST


Message-id: <3B58C8B9.22F69D1A@alvie-mail.lanl.gov>


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





About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 10 Mar 2004 - 08:18:21 EST