[R] lang2(...) with two and more arguments
Prof Brian Ripley
ripley at stats.ox.ac.uk
Mon Nov 3 17:11:52 CET 2003
You set the first argument to x and then to y. Why are you surprised?
On Mon, 3 Nov 2003, [koi8-r] "Timur Elzhov[koi8-r] " wrote:
> Dear R-help,
>
> how could I create an R call in C code using lang2 with 2 and more
> arguments? I tried this code:
>
> SEXP f(SEXP fn, SEXP rho)
> {
> SEXP R_fcall, x, y;
>
> PROTECT(R_fcall = lang2(fn, R_NilValue));
> PROTECT(x = allocVector(REALSXP, 1));
> PROTECT(y = allocVector(REALSXP, 1));
>
> REAL(x)[0] = 10;
> REAL(y)[0] = 20;
>
> SETCADR(R_fcall, x);
> SETCADR(R_fcall, y);
>
> UNPROTECT(3);
>
> return R_fcall;
> }
>
> .Call("f", c, new.env()) returns
>
> `.Primitive("c")(20)', but not `.Primitive("c")(10, 20)',
> as I expected. How can I recieve the disired result?
>
> Thank you very much.
>
> --
> WBR,
> Timur.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list