search for: r_tryeval

Displaying 20 results from an estimated 57 matches for "r_tryeval".

2009 Sep 29
3
How do I access class slots from C?
...tData,portConstr,portVal,portWeights,tsAssets,tsReturns,nAssets,reciprocal; int errorOccurred,nx,ny,i,j; double *v; const char *x,*y; Rf_initEmbeddedR(argc, argv); // loading fPortfolio PROTECT(e = lang2(install("library"), mkString("fPortfolio"))); R_tryEval(e, R_GlobalEnv, NULL); UNPROTECT(1); // creating a default portfolioSpec object PROTECT(e=lang1(install("portfolioSpec"))); PROTECT(portSpec=R_tryEval(e,R_GlobalEnv, NULL)); // creating a portfolioData object PROTECT(e=lang4(install("c"),mkString("S...
2016 Jul 07
1
Detecting user interrupts in R_tryEval
Is there any way to distinguish between an error and a user interruption in R_tryEval? In both cases the ErrorOccurred argument is set to 1. For my application I need a different action in case of a SIGINT. >From the source code I infer that R_tryEval basically wraps eval in R_ToplevelExec, which returns TRUE if fun returns normally, FALSE if it results in a jump to top level. H...
2009 Nov 14
1
R_tryEval for OCaml-R.
Hello. I'm currently working on the OCaml-R binding allowing to call R code from Objective Caml. As Objective Caml is a functional language, I'd like the binding to be as 'functional' as possible. Specifically, this means that I'd like using the R_tryEval function and all related entry points in libR.so. I've had a look at R-exts.pdf, but R_tryEval is not documented. Could someone please point me to relevant documentation, or the relevant part of the R source code? All the best, -- Guillaume Yziquel http://yziquel.homelinux.org/
2009 Sep 16
2
I want to get a reference to this time series object
...char** argv) { SEXP e,c,portSpec,portData,portConstr,portVal,tsAssets; int errorOccurred,nx,ny,i,j; double *v; const char *x,*y; Rf_initEmbeddedR(argc, argv); // loading fPortfolio PROTECT(e = lang2(install("library"), mkString("fPortfolio"))); R_tryEval(e, R_GlobalEnv, NULL); UNPROTECT(1); // creating a default portfolioSpec object PROTECT(e=lang1(install("portfolioSpec"))); PROTECT(portSpec=R_tryEval(e,R_GlobalEnv, NULL)); // creating a portfolioData object PROTECT(e=lang4(install("c"),mkString("S...
2007 Apr 06
2
wishlist: additional argument in R_tryEval (Rinternals.h)
Hi, R_tryEval, exported in Rinternals.h but not part of the API, is currently defined as: R_tryEval(SEXP e, SEXP env, int *ErrorOccurred); I'm trying to embed R in an application (basically yet another GUI), and this has been very helpful to catch errors. It would be even more helpful if it also gave acces...
2007 Feb 22
1
R_tryEval not properly documented in 'Writing R Extensions' (PR#9524)
Full_Name: Byron Ellis Version: 2.4.1 OS: N/A Submission from: (NULL) (75.55.126.10) R_tryEval is implied to be in the public API by 'Embedding R in Other Applications,' but not documented in 'Writing R Extensions.' This would seem to be an oversight given the dependence of many applications including but not limited to the official OS X GUI on this function.
2009 Jun 16
1
calling handlers within R_tryEval
Hello, When using R_tryEval (from JRI in my case), is there a way to setup error recovery strategy and more generally calling handlers. From my reading of context.c, R_tryEval calls R_ToplevelExec which creates a context like this: begincontext(&thiscontext, CTXT_TOPLEVEL, R_NilValue, R_GlobalEnv, R_BaseE...
2009 Aug 25
2
Clarifications please.
...onfused on how the lang 1 2 3 4 ... set of functions work. I haven't found any relevant documentation explaining it clearly. I have a vague idea but still I cannot understand how I would evaluate an R expression like Covariance <- round(cov(100 * SWX.RET), digits = 4) using lang, install and R_tryEval. 2) What exactly does install do? 3) I wrote the following code: #include <Rinternals.h> #include <Rembedded.h> int main (int argc, char** argv) { SEXP e,val; int errorOccurred; Rf_initEmbeddedR(argc, argv); // library("fPortfolio") PROTECT(e = lang2...
2007 Feb 22
0
R_tryEval not properly documented in 'Writing R Extensions' (PR#9525)
On Thu, 22 Feb 2007, ellis at stat.harvard.edu wrote: > Full_Name: Byron Ellis > Version: 2.4.1 > OS: N/A > Submission from: (NULL) (75.55.126.10) > > > R_tryEval is implied to be in the public API by 'Embedding R in Other > Applications,' but not documented in 'Writing R Extensions.' This would seem to > be an oversight given the dependence of many applications including but not > limited to the official OS X GUI on this function....
2013 Mar 06
1
Printing warning messages around R_tryEval
Hi! In RKWard we use R_tryEval() at a number places to run R commands. In order to make sure that any generated warnings become visible close to the problem, we were following up (most of) these calls with Rf_PrintWarnings(). Rf_PrintWarnings() was never available in the headers (as far as I know), and in r61771 the symbol h...
2007 Feb 21
3
non-interactive R_tryEval does not return
...at least I think that is what happens, at least on some configurations. Here's a repeatable example: cd R_HOME/tests/Embedding touch tmp.R make tryEval and then (correct) > ./tryEval --slave Error in sqrt("") : Non-numeric argument to mathematical function Caught an error calling sqrt(). Try again with a different argument. [1] 3 versus (non-interactive; no return) >
2023 Apr 23
1
Warnings created during R_eval or R_tryEval not shown before R ending or R error.
Hi, I have an embedded R, with the evaluation of expressions happening over time during the lifespan of the process. I tried either `R_eval()` and `R_tryEval()` for the evaluation. The issue I have is that the processing of warnings does not happen until the process exits and/or R is shut down. Evaluating `warnings()` returns NULL (NILSXP). It seems like the warnings are stuck in a list out of `warnings()`'s reach, waiting to be processed. I cannot...
2004 Oct 08
2
R-2.0.0 findVar and findFun question
Dear all, when working on a project with embedded R, I found out that R-2.0.0 causes a problem where older versions worked OK. Rf_findVar(...) causes the following error when used to find a generic function (such as print): fun = Rf_findVar(...); R_tryEval(fun, ...); Error in function (object, ...) : Invalid generic function in usemethod Alternatively, using Rf_findFun(...) seems OK in this context, but crashes if you call it with an unexisting function name. Rf_findVar does not crash in this case, but returns an unbound value. My workaround for...
2023 Apr 26
1
Warnings created during R_eval or R_tryEval not shown before R ending or R error.
? Sun, 23 Apr 2023 13:33:16 -0400 Laurent Gautier <lgautier at gmail.com> ?????: > When tracing what happens during an error I found that > verrorcall_dflt() in src/main/errors.c calls PrintWarnings(). That > function is not part of R's C-API though. I've tried reading the source code and came to a similar conclusion. PrintWarnings() is required for warnings() to work
2009 Jan 08
1
Callbacks seems to get GCed.
...hods[] = { {"set_callback1", (DL_FUNC) &set_callback1, 1}, {"set_callback2", (DL_FUNC) &set_callback2, 1}, {NULL} }; void r_trigger_callback1() { int errorOccurred; SEXP f = NULL; f = allocVector(LANGSXP, 1); SETCAR(f, callback1); PROTECT(f); R_tryEval(f, R_GlobalEnv, &errorOccurred); UNPROTECT(1); } void r_trigger_callback2() { int errorOccurred; SEXP f = NULL; f = allocVector(LANGSXP, 1); SETCAR(f, callback2); PROTECT(f); R_tryEval(f, R_GlobalEnv, &errorOccurred); UNPROTECT(1); } void r_exec(char *code) {...
2007 Aug 16
0
call R function in c++ program
...ent defineVar(install("variable_name"), variable_value_SEXP, rho); // for execute "complex" function (with parser) PROTECT( e1 = mkString("plot(variable_name, type=\"l\")") ); PROTECT( e2 = R_ParseVector(e1, 1, &status, R_NilValue) ); R_tryEval(VECTOR_ELT(e2,0), rho, &hadError); UNPROTECT(2); // for execute "simple" function (without parser) PROTECT( e1 = lang3(install(":"), ScalarInteger(1), ScalarInteger(4)) ); PROTECT( e2 = lang4(install("matrix"), e1, ScalarInteger(4), ScalarInteger(1)...
2009 May 10
2
In C, a fast way to slice a vector?
Hello, Suppose in the following code, PROTECT(sr = R_tryEval( .... )) sr is a RAWSXP vector. I wish to return another RAWSXP starting at position 13 onwards (base=0). I could create another RAWSXP of the correct length and then memcpy the required bytes and length to this new one. However is there a more efficient method? Regards Saptarshi Guha
2012 Feb 01
3
Crash in R using embedded.
...t.txt\", sep = \"\"), open=\"wt+\")\nsink(f)\n"; PROTECT(cmdSexp = allocVector(STRSXP, 1)); SET_STRING_ELT(cmdSexp, 0, mkChar(rcommand.c_str())); cmdexpr = PROTECT(R_ParseVector(cmdSexp, -1, &status, R_NilValue)); for(int i = 0; i < length(cmdexpr); i++) { R_tryEval(VECTOR_ELT(cmdexpr, i),NULL,&error); } UNPROTECT(2); [[alternative HTML version deleted]]
2019 Apr 05
2
Parsing code with newlines
...dError; ParseStatus status; init_R(argc, argv); PROTECT(tmp = mkString("\n\r ls()")); PROTECT(e = R_ParseVector(tmp, 1, &status, R_NilValue)); if (status != PARSE_OK) { printf("boo boo\n"); } else { PrintValue(e); R_tryEval(VECTOR_ELT(e,0), R_GlobalEnv, &hadError); } UNPROTECT(2); end_R(); return(0); } -- Mikhail
2010 Sep 09
0
calling Rf_initEmbeddedR error
...uot;}; int Argc2 = 1; char *Argv2[] = {"Rtest_2"}; // Init R(first) Rf_initEmbeddedR(Argc1, Argv1); // R package load SEXP e = R_NilValue; SEXP r = R_NilValue; PROTECT(e = lang2(install("source"), mkString("hreg.r"))); r = R_tryEval(e, R_GlobalEnv, NULL); // -----> success UNPROTECT(1); // Function load SEXP fun; PROTECT(e = allocVector(LANGSXP, 3)); fun = findFun(install("hreg"), R_GlobalEnv); if(fun == R_NilValue) // -----> success { UNPR...