[R] Call to rgamma using .C causes R to hang
Steve Pederson
stephen.pederson at adelaide.edu.au
Tue Jul 20 09:50:49 CEST 2010
Hi,
I've been trying to get this working for ages, but it causes R to hang.
Here is my C code saved as test1.c
# include <R.h>
# include <Rmath.h>
void test1 (double *x, double *result)
{
result[0] = rgamma(*x, 2.0);
}
This was compiled using R CMD SHLIB test1.c & loaded in R using:
dyn.load("test1.dll")
out <- .C("test1",x=as.double(2),random=double(1))
R then hangs
However, if I change "rgamma" in the above to be "rnorm" or "runif",
everything works just fine. I'm not sure if it matters, but the function
'rgamma' under R works OK.
I'm running Windows XP & I followed the instructions at
http://cran.r-project.org/doc/manuals/R-admin.html#Windows-standalone
after building R from source.
Thanks,
Steve
More information about the R-help
mailing list