Skip to content
Prev 48539 / 63424 Next

Need help on calling Head from C

Hi,
On 06/26/2014 01:36 PM, Radford Neal wrote:
How true but who can blame him? The Writing R Extensions manual
contains the same mistake:

   SEXP mkans(double x)
   {
     SEXP ans;
     ans = PROTECT(allocVector(REALSXP, 1));
     REAL(ans)[0] = x;
     UNPROTECT(1);
     return ans;
   }

   double feval(double x, SEXP f, SEXP rho)
   {
     defineVar(install("x"), mkans(x), rho);
     return REAL(eval(f, rho))[0];
   }

Reported here more than 6 years ago and never fixed:

   https://stat.ethz.ch/pipermail/r-devel/2008-January/048040.html

Cheers,
H.