[R] C Interface in R

2013-07-17 Thread ivo welch
Dear R Users--- I spent some time implementing the AS75 WLS regression algorithm in C in order to learn the R interface to C. I did not find an easy, brief C+R example of an algorithm that used persistent storage across calls. they probably exist, but I could not find a nice brief template for

[R] C interface

2010-06-18 Thread michael meyer
Greetings, I am trying to call simple C-code from R. I am on Windows XP with RTools installed. The C-function is #include R.h #include Rinternals.h #include Rmath.h #include Rdefines.h // prevent name mangling extern C { SEXP __cdecl test(SEXP s){ SEXP result; PROTECT(result =

Re: [R] C interface

2010-06-18 Thread Romain Francois
Hello, This is not the appropriate mailing list. Use R-devel for questions about C, etc ... One thing that might help you is the inline package. require( inline ) fx - cfunction( signature( s = numeric ), ' SEXP result; PROTECT(result = NEW_NUMERIC(1)); double*

Re: [R] C interface

2010-06-18 Thread Matt Shotwell
Michael, Your function 'test' doesn't utilize any C++ features. Is there another reason you are using a C++ compiler (g++)? If not, why not just use a C compiler? You can then get rid of the 'extern C{}' wrapper, the '__cdecl' declaration, and the MAKEFLAGS variable. Also, you may know that the

[R] C Interface

2010-06-18 Thread michael meyer
Thanks for all replies. I will post the question on R-develop also since eventually I would like to compile more substantial C and C++ code into shared libraries. Michael [[alternative HTML version deleted]] __ R-help@r-project.org mailing