Hi, I would like to interface a C code into R. Is it possible to use in the C code, functions from a R package (for instance, to use pmvnorm within loops in the C code and to call the result in a R function)? Nathalie
I think "Writing R Extensions" may help you with that... On Tue, 4 Nov 2003, Peyrard Nathalie wrote:> Date: Tue, 04 Nov 2003 10:19:00 +0100 > From: Peyrard Nathalie <Nathalie.Peyrard at avignon.inra.fr> > To: r-help at stat.math.ethz.ch > Subject: [R] interfacing C into R and R packages > > Hi, > > I would like to interface a C code into R. Is it possible to use in the C code, functions from a R package (for instance, to use pmvnorm within loops in the C code and to call the result in a R function)? > > Nathalie > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help >-- Cheers, Kevin --------------------------------------------------------------- Ko-Kang Kevin Wang Master of Science (MSc) Student SLC Tutor and Lab Demonstrator Department of Statistics University of Auckland New Zealand Homepage: http://www.stat.auckland.ac.nz/~kwan022 Ph: 373-7599 x88475 (City) x88480 (Tamaki)
Hello, I'm not sure, but if I understand your question well, we have had such questions already plenty of times. I guess, Google/STFW/RTFM/writing R extensions. It's easy, it's well-explained, ... Kurt. Peyrard Nathalie wrote:> Hi, > > I would like to interface a C code into R. Is it possible to use in > the C code, functions from a R package (for instance, to use pmvnorm > within loops in the C code and to call the result in a R function)? > > Nathalie
> Hi, > > I would like to interface a C code into R. Is it possible to use in the C code, functions from a R package (for instance, to use pmvnorm within loops in the C code and to call the result in a R function)?Probably the most easiest way is copying the C-sources from the original package (that's what GPL is about). In this special case you need to (re)-write the R high level function `pmvnorm' in C and call the Fortran77 subroutine `MVTDST' from your C-code. However, keep in mind that `MVTDST' requires significant time for non-trivial problems and you should make sure that re-coding the interface in C is worth the effort: Note that you can call R functions from C anyway (Section 4.9 of `Writing R Extensions'). Best, Torsten> > Nathalie > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > >