Displaying 1 result from an estimated 1 matches for "kernel_smooth".
2005 Oct 28
1
Calling R functions from C
...face 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 extensi...