Dear R users,

I read on the "Introduction to the .C Interface to R" by Peng & Leeuw 
(http://www.biostat.jhsph.edu/~rpeng/docs/interface.pdf) that it is 
possible to use a few R functions (such as "dnorm") within C by 
including the "Rmath.h" header file in your C code:
e.g.

#include <R.h>
#include <Rmath.h>
void kernel_smooth(double *x, int *n, double *xpts, int *nxpts,
double *h, double *result)
{
int i, j;
double d, ksum;
for(i=0; i < *nxpts; i++) {
ksum = 0;
for(j=0; j < *n; j++) {
d = xpts[i] - x[j];
ksum += dnorm(d / *h, 0, 1, 0);
}
result[i] = ksum / ((*n) * (*h));
}
}


In the manual "Writing R extensions" there is also a list of special 
functions which can be called in C.

I was wondering whether there is a way to call any other R functions 
similarly. Is there any documented exemple available somewhere?

Thanks a lot for your help,

Florent

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to