search for: r_fcall

Displaying 14 results from an estimated 14 matches for "r_fcall".

2003 Nov 03
2
lang2(...) with two and more arguments
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,...
2008 Apr 24
1
Calling R functions with multiple arguments from C
...bmitted by Timur Elzhov on the the R mailing list under the discussion Calling R function from within C code that I've modified. I've read that discussion, but still got stuck. Could anybody point me in the right direction? SEXP foo(SEXP fn, SEXP elmt1, SEXP elmt2, SEXP rho) { SEXP R_fcall, args, ans,s; PROTECT( args = s = allocList(2)); PROTECT( R_fcall = lang2(fn, R_NilValue) ); SETCAR(s,elmt1); SET_TAG(s,install("x")); s = CDR(s); SETCAR(s,elmt2); SET_TAG(s,install("y")); SETCADR( R_fcall, args); PROTECT( ans = eval(R_fca...
2009 May 26
1
passing "..." arguments to a function called by eval()
...TestC",x[1],dnorm,...,rho=new.env(),PACKAGE="pkg") return(retVal) } ########## C code, in pkg/src directory SEXP dTestC(SEXP dblX, SEXP funFn, SEXP dots, SEXP rho); /*--------------------------*/ SEXP dTestC(SEXP dblX, SEXP funFn, SEXP dots, SEXP rho){ SEXP retVal; SEXP R_fcall; PROTECT(retVal = NEW_NUMERIC(1)); PROTECT(R_fcall = lang3(funFn, R_NilValue, R_NilValue)); SETCADR(R_fcall, dblX); SETCADDR(R_fcall, dots); retVal = eval(R_fcall, rho); UNPROTECT(2); return(retVal); } ######################## When I call the dTest() function, the first required...
2017 Jun 05
2
Usage of PROTECT_WITH_INDEX in R-exts
Hi I've noted a minor inconsistency in the documentation: Current R-exts reads s = PROTECT_WITH_INDEX(eval(OS->R_fcall, OS->R_env), &ipx); but I believe it has to be PROTECT_WITH_INDEX(s = eval(OS->R_fcall, OS->R_env), &ipx); because PROTECT_WITH_INDEX() returns void. Best regards Kirill
2017 Jun 06
2
Usage of PROTECT_WITH_INDEX in R-exts
...t; Kirill M?ller <kirill.mueller at ivt.baug.ethz.ch> >>>>>> on Mon, 5 Jun 2017 17:30:20 +0200 writes: > > Hi I've noted a minor inconsistency in the documentation: > > Current R-exts reads > > > s = PROTECT_WITH_INDEX(eval(OS->R_fcall, OS->R_env), &ipx); > > > but I believe it has to be > > > PROTECT_WITH_INDEX(s = eval(OS->R_fcall, OS->R_env), &ipx); > > > because PROTECT_WITH_INDEX() returns void. > > Yes indeed, thank you Kirill! > > note that the same is...
2017 Jun 09
1
Usage of PROTECT_WITH_INDEX in R-exts
...t.baug.ethz.ch> on >>>>>>>> Mon, 5 Jun 2017 17:30:20 +0200 writes: >>> > Hi I've noted a minor inconsistency in the >>> documentation: > Current R-exts reads >>> >>> > s = PROTECT_WITH_INDEX(eval(OS->R_fcall, OS->R_env), >>> &ipx); >>> >>> > but I believe it has to be >>> >>> > PROTECT_WITH_INDEX(s = eval(OS->R_fcall, OS->R_env), >>> &ipx); >>> >>> > because PROTECT_WITH_...
2017 Jun 06
0
Usage of PROTECT_WITH_INDEX in R-exts
>>>>> Kirill M?ller <kirill.mueller at ivt.baug.ethz.ch> >>>>> on Mon, 5 Jun 2017 17:30:20 +0200 writes: > Hi I've noted a minor inconsistency in the documentation: > Current R-exts reads > s = PROTECT_WITH_INDEX(eval(OS->R_fcall, OS->R_env), &ipx); > but I believe it has to be > PROTECT_WITH_INDEX(s = eval(OS->R_fcall, OS->R_env), &ipx); > because PROTECT_WITH_INDEX() returns void. Yes indeed, thank you Kirill! note that the same is true for its partner function|macro REPROTECT()...
2017 Jun 08
0
Usage of PROTECT_WITH_INDEX in R-exts
...;kirill.mueller at ivt.baug.ethz.ch> >>>>>>> on Mon, 5 Jun 2017 17:30:20 +0200 writes: >> > Hi I've noted a minor inconsistency in the documentation: >> > Current R-exts reads >> >> > s = PROTECT_WITH_INDEX(eval(OS->R_fcall, OS->R_env), &ipx); >> >> > but I believe it has to be >> >> > PROTECT_WITH_INDEX(s = eval(OS->R_fcall, OS->R_env), &ipx); >> >> > because PROTECT_WITH_INDEX() returns void. >> >> Yes indeed, thank you Kirill!...
2003 Jan 16
1
Calling R function from within C code
Dear R experts, I'd like to call R function from within C code. I looked through the 'R exts' manual, found examples with lang2(R_fcall, list), and tried it, but it seemed to create the call, which can accept only a single argument of 'list' type, when I need to create the call of R functions with arbitrary numbers of arguments. How can I do it? Thanks a lot. -- WBR, Timur.
2009 Sep 15
1
How can I use R:sort function in C code?
Hi, I wrote a C extension for R. Within the C code I wanted to invoke the R's sort function, with the argument "index.return = TRUE". I found it is a difficult problem, how can I do that? I have implemented the decreasing sorting by the code "PROTECT(R_fcall = lang3(install("sort"), x, desc));", but how to define the "index.return" argument? Thanks in advanced! -- Guozhu. Wen mail: guozhuwen@gmail.com douban: http://www.douban.com/people/wentrue/ blog: http://www.wentrue.net/blog/ twitter: https://twitter.com/wentrue [[alt...
2000 May 22
0
memory problem with DEC C (was: problem with glm (PR#452))
...particular problem if I make a small change in lapply in > > its main loop. Around line 50 of apply.c: > > > > PROTECT(ans = allocVector(VECSXP, n)); > > for(i = 0; i < n; i++) { > > INTEGER(ind)[0] = i + 1; > > VECTOR(ans)[i] = eval(R_fcall, rho); > > } > > > > if I change it to make an assignment to a > > temporary variable first everything seems to work fine: > > > > PROTECT(ans = allocVector(VECSXP, n)); > > for(i = 0; i < n; i++) { > > INTEGER(ind)[0] = i + 1...
2008 Mar 07
1
parameters for lbfgsb (function for optimization)
...optimfn fn, optimgr gr, int *fail, void *ex, double factr, double pgtol, int *fncount, int *grcount, int maxit, char *msg, int trace, int nREPORT); What do I put for parameter ex (11th parameter)? I looked at optim.c codes at R sites and it's a structure that has bunch of objects such as SEXP R_fcall, SEXP R_gcall, SEXP R_env, double* ndeps, etc. I cannot figure out what it is about. How about fncount, rcount? R-ext.pdf or R help does not explain it in detail. Any comments would help. Thank you. [[alternative HTML version deleted]]
2008 Feb 24
1
R-2.6.2 installation (64bit) falling over with the grid package
..., the unit.c part in particular. This is the output I get: gcc -std=gnu99 -I../../../../include -I../../../../include -I/usr/local/include -fvisibility=hidden -fpic -g -O2 -c unit.c -o unit.o unit.c: In function ??pureNullUnit??: unit.c:332: error: stray ??#?? in program unit.c:332: error: ??R_fcall?? undeclared (first use in this function) unit.c:332: error: (Each undeclared identifier is reported only once unit.c:332: error: for each function it appears in.) make[5]: *** [unit.o] Error 1 make[5]: Leaving directory `/usr/local/R-2.6.2/src/library/grid/src' make[4]: *** [all] Error 2 make[...
1999 Dec 20
1
Manual: writing R Extensions (PR#380)
...ink it should read REAL(version) = 3.0; ^^^^^^^ page 23, second example, I think the parameter definition should read SEXP lapply2(SEXP list, SEXP fn, SEXP rho) ^^ and the last line of the function I guess should be VECTOR(ans)[i] = eval(R_fcall, rho); ^^^^^^^^ If my understanding is wrong or you discover another typo in the lapply2 example, please give me a short note. Regards -- Dr. Jens Oehlschlägel-Akiyoshi MD FACTORY GmbH Bayerstrasse 21 80335 München Tel.: 089 545 28-27 Fax.: 089 545 28-10 http...