search for: lcon

Displaying 9 results from an estimated 9 matches for "lcon".

Did you mean: leon
2014 Feb 26
1
help with gotoExitingHandler(R_NilValue, call, entry); . Implementation of error handling internally
...rror handling; do not reset stack */ else { SEXP hooksym, hcall, qcall; /* protect oldstack here, not outside loop, so handler stack gets unwound in case error is protect stack overflow */ PROTECT(oldstack); hooksym = install(".handleSimpleError"); PROTECT(qcall = LCONS(R_QuoteSymbol, LCONS(call, R_NilValue))); PROTECT(hcall = LCONS(qcall, R_NilValue)); hcall = LCONS(mkString(buf), hcall); hcall = LCONS(ENTRY_HANDLER(entry), hcall); PROTECT(hcall = LCONS(hooksym, hcall)); eval(hcall, R_GlobalEnv); UNPROTECT(4); } } else gotoExitingHan...
2004 Jul 06
1
Wrong object type produced - LANGSXP should be LISTSXP (PR#7055)
...15 05:40:35.000000000 -0500 +++ gram.y 2004-07-06 13:45:10.000000000 -0400 @@ -731,11 +731,11 @@ static SEXP xxsubscript(SEXP a1, SEXP a2, SEXP a3) { SEXP ans; if (GenerateCode) - PROTECT(ans = LCONS(a2, LCONS(a1, CDR(a3)))); + PROTECT(ans = LCONS(a2, CONS(a1, CDR(a3)))); else PROTECT(ans = R_NilValue); UNPROTECT_PTR(a3); UNPROTECT_PTR(a1); return ans;
2017 Jun 27
2
paste strings in C
...s, setting the rownames of colnames in R copies the matrix and costs a lot of memory and time in the process. Having all necessary headers in C, the solution I came up with involves calling the function foo() from within C: SEXP test(SEXP mymat, SEXP colnms, SEXP tilde) { SEXP call = PROTECT(LCONS(install("foo"), LCONS(mymat, LCONS(colnms, LCONS(tilde, R_NilValue))))); SEXP out = PROTECT(eval(call, R_GlobalEnv)); UNPROTECT(2); return(out); } After compilation, say in a file called test.c, back...
2017 Jun 27
0
paste strings in C
...n R copies the matrix and > costs a lot of memory and time in the process. > > Having all necessary headers in C, the solution I came up with involves > calling the function foo() from within C: > > SEXP test(SEXP mymat, SEXP colnms, SEXP tilde) { > > SEXP call = PROTECT(LCONS(install("foo"), > LCONS(mymat, > LCONS(colnms, > LCONS(tilde, R_NilValue))))); > > SEXP out = PROTECT(eval(call, R_GlobalEnv)); > > UNPROTECT(2); > return(out); > } > > &g...
2005 Aug 17
2
About R variable references
...SEXP myexec(/* probably has some parameters that are omitted in this example */) { int state; SEXP thecall; /* do some work, then set the state and call a callback function if necessary */ PROTECT(myvariable); INTEGER(myvariable)[0] = state; UNPROTECT(1); if(state) { PROTECT(thecall = LCONS(myfunction, LCONS(myvariable, R_NilValue))); eval(thecall, myrho); UNPROTECT(1); } return R_NilValue; } ######################################################################## ######## # R CODE ##################################################################### myinit<-function(va...
2020 Jun 30
3
Build a R call at C level
On 6/30/20 1:06 PM, Jan Gorecki wrote: > It is quite known that R documentation on R C api could be improved... Please see "5.11 Evaluating R expressions from C" from "Writing R Extensions" Best Tomas > Still R-package-devel mailing list should be preferred for this kind > of questions. > Not sure if that is the best way, but works. > > call_to_sum <-
2010 Jan 14
1
how to call a function from C
...hange). To call the function, what we do is generate a call with the function as the first node and then evaluate the call. SEXP stats = PROTECT( R_FindNamespace( mkString( "stats") ) ); SEXP rnorm = PROTECT( findVarInFrame( stats, install( "rnorm") ) ) ; SEXP call = PROTECT( LCONS( rnorm, CONS( ScalarInteger(10), CONS(ScalarReal(0), R_NilValue ) ) ) ); SEXP res = PROTECT( eval( call , R_GlobalEnv ) ); UNPROTECT(4) ; return res ; It works, but I was wondering if there was another way. I've seen applyClosure, but I'm not sure I should attempt to use it or if using...
2014 Mar 06
1
Create dataframe in C from table and return to R
...STRING_ELT(lsnm,0,mkChar("int")); SET_STRING_ELT(lsnm,1,mkChar("string")); for ( i = 0 ; i < 3; i++ ) { SET_STRING_ELT(dfStr,i,mkChar(ab[i])); INTEGER(dfint)[i] = sn[i]; } SET_VECTOR_ELT(df,0,dfint); SET_VECTOR_ELT(df,1,dfStr); setAttrib(df,R_NamesSymbol,lsnm); //PROTECT(dfm=LCONS(dfm,list3(dfm,R_MissingArg,mkFalse()))); UNPROTECT(4); dfm = PROTECT(lang2(install("data.frame"),df)); SEXP res = PROTECT(eval(dfm,R_GlobalEnv)); UNPROTECT(2) } ------------------------------------------------------------------------ It works fine but i want it the other way the ou...
2020 Jun 30
0
Build a R call at C level
Thanks Jan and Tomas for the feedback. Answer from Jan is what I am looking for. Maybe I am not looking in the right place buy it is not easy to understand how these LCONS, CONS, SETCDR...etc works. Thank you Best regards Morgan On Tue, 30 Jun 2020, 12:36 Tomas Kalibera, <tomas.kalibera at gmail.com> wrote: > On 6/30/20 1:06 PM, Jan Gorecki wrote: > > It is quite known that R documentation on R C api could be improved... > > Please see &quo...