k****n 发帖数: 81 | 1 关键是如何编译程序。
弄了老半天也没弄明白。
多谢! | n******0 发帖数: 61 | 2 google some introduction or read R extesion,
example cited from "An Introduction to the .C Interface to R":
#include
#include
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); // see use R function in C code
}
result[i] = ksum / ((*n) * (*h));
}
} |
|