[R] lang2(...) with two and more arguments
bates at stat.wisc.edu
Tue Nov 4 16:28:33 CET 2003
Timur Elzhov <Timur.Elzhov at jinr.ru> writes:
> On Tue, Nov 03, 2003 at 17:06:37 +0100, you wrote:
> >> REAL(x) = 10;
> >> REAL(y) = 20;
> >> SETCADR(R_fcall, x);
> >> SETCADR(R_fcall, y);
> >> ...
> >> .Call("f", c, new.env()) returns
> >> `.Primitive("c")(20)'
> > Hmmm. This is definitely not right:
> > SETCADR(R_fcall, x);
> > SETCADR(R_fcall, y);
> > sets the same location first to x, and then to y. I suspect you need
> > SETCADDR(R_fcall, y);
> > but no guarantees...
> This returns message `bad value'.
> Ok! the question is: How can I create a call with, say, 10
> arguments? I mean C code, of course :)
Better look at your example more closely. lang2 is used to create a
function call with *one* argument. lang2 itself takes two arguments:
the name (i.e. an SEXP of type name) of the function and an SEXP to
You create a function call of two arguments with lang3 and a function
call of three arguments with lang4. After that I think you have to
cons up a (lisp-like) list yourself.
This discussion probably belongs on r-devel not r-help.
More information about the R-help