Displaying 20 results from an estimated 30 matches for "findvar".
Did you mean:
indvar
2009 Aug 20
2
Problem using findVar( ) in combination with R's lazy evaluation
Hi All,
I have a few small questions about the usage of the C findVar( ) function
when used in C code called with '.Call'. In my case I create an R function
with an argument. This function calls some C code in which I use findVar( )
to retrieve the values from the argument. Ofcourse normally I would just
give the values as argument to .Call, but in my project...
2009 Nov 28
1
PROTECT and OCaml GC.
Hello.
In the writing of my OCaml-R binding, I'm sort of confused when it comes
to the use of the PROTECT and UNPROTECT macros.
Basically, I have C stub functions that are in charge of calling R for
everything. Here's a simple example:
> CAMLprim value r_findvar (value symbol) {
> /* The findVar function is defined in envir.c. It looks up a symbol
> in an environment. */
> CAMLparam1(symbol);
> CAMLreturn(Val_sexp(findVar(Sexp_val(symbol), R_GlobalEnv)));
> }
This simply makes a call to findVar and returns the value to Objective...
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 wit...
2008 May 24
1
value returned by findFun when the name cannot be found.
Dear list,
I have been using "findVar" (defined in src/main/envir.c) happily and
would like to use
"findFun".
However I have trouble when the name searched cannot be found: while
"findVar" returns R_UnboundValue,
"findFun" does not (the 4 last lines of "findFun" are copied below).
erro...
2001 Apr 14
1
Postscript font bugs (and a suggestion) (PR#914)
...ecause only fonts numbered
1..5 are actually defined. I don't know how to fix it.
2. The ?postscript help topic refers to .ps.profile; the actual
variable name is .ps.prolog. The C source in main/devPS.c has this
on lines 606-608, with the incorrect name in the error message:
prolog = findVar(install(".ps.prolog"), R_GlobalEnv);
if(!isString(prolog))
error("Object .ps.profile is not a character vector");
3. And this is a suggestion, not a bug: I'd like to change the font
definitions by changing the .ps.prolog instructions, but devPS.c puts
the...
2003 Sep 29
0
Calling C fn crashes (PR#4281)
Full_Name: Ben K.
Version: 1.7.1
OS: Win 2000
Submission from: (NULL) (208.243.20.222)
This C code doesn't crash:
void init(SEXP rho, int *o){
SEXP vars = findVar(install("vars"), rho);
}
It's called using:
vars <-as.data.frame(NULL)
vars$delta <-7
dyn.load("c_fns.dll")
print(.C("init",.GlobalEnv,o=as.integer(3))$o)
However, this does crash (``Rgui has generated errors and will be closed by
Windows'...
2010 Aug 21
1
Speed improvement to evalList
...ignore it and return the cdr with all its expressions evaluated;
* if it is bound to a ... list of promises,
* we force all the promises and then splice
* the list of resulting values into the return value.
* Anything else bound to a ... symbol is an error
*/
h = findVar(CAR(el), rho);
if (TYPEOF(h) == DOTSXP || h == R_NilValue) {
while (h != R_NilValue) {
if (mode==1) {
PROTECT(head);
mode = 2;
}
ev = CONS(eval(CAR(h), rho), R_NilValue);...
2008 Jan 16
1
Pb with defineVar() example in the "Writing R Extensions" manual
...o I end up with a lot of symbols in the rho environment.
The problems I've seen are hard to reproduce: sometimes it's a segfault,
sometimes a "cons memory exhausted" error, or sometimes everything looks
fine except that, later, when I retrieve values from the rho environment
with findVar(), some of them are altered!
But if I replace the above line by:
PROTECT(ans = mkans(x));
defineVar(install(somekey), ans, rho);
UNPROTECT(1);
then everything works fine :-)
Cheers,
H.
2013 Oct 16
1
Parallel R expression evaluations
...y C++ code.
I am facing an error while executing more than 1 R-expressions parallelly.
I am executing round(X) and abs(X) parallelly on a set of 50 input rows
which resulted in segmentation fault after getting the following errors.
Error: unprotect_ptr: pointer not found
Error: argument to 'findVar' is not an environment
I am using the following code snippet for initializing R, parsing and
evaluation of R expression
// For initialization
int res= Rf_initEmbeddedR(R_argc, (char**)R_argv);
// For parsing and evaluation
SEXP cmd1= Rf_mkChar(rscript);
SEXP cmdSexp, cmdex...
1998 Jan 03
1
R-beta: NextMethod(.Generic) bug
I'm a day-old R newbie (but a war-weary S veteran), with couple of
first-day questions:
In R 0.61, this code fails.
Ops.test <- function(e1,e2)
{
e1 <- NextMethod(.Generic)
e1
}
x <- 4
class(x) <- "test"
y <- x < 3
The error message is "Error in NextMethod(.Generic) : negative length vectors
are not allowed.".
I assume it is a bug.
2006 May 19
1
UseMethod infelicity
...earch from as I think we need to avoid
mycoef <- function(x)
{
mycoef <- function(x) stop("not this one")
UseMethod("mycoef")
}
so I used ENCLOS(env).
This adds some overhead, hopefully no more than searching for methods.
BTW, I noticed that R_LookupMethod uses findVar, that is looks for any
object not for functions: that must be another infelicity.
--
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,...
2005 Aug 17
2
About R variable references
...ion. I have tried to look for one but until now
without success.
My question is: can you see a design flaw here or is everything done
according to R requirements and hence it is likely that there is a bug
in my own code?
One dirty correction I can see but have not tried is to use object names
and findVar but this would make it less flexible (at least IMHO).
I have quickly browsed the forums and the documentation I was able to
find but found no answers.
My system is FC3 with R version >= 2.
There are two snippets of code that hopefully make clear what I am
trying to achieve. The code is provid...
2014 Feb 11
1
getting environment from "top" promise
...{
ans <- callNextMethod()
ans@nrow <- nrow(ans@df)
ans
})
b <- new("B", df=mtcars)
dropLowMpg(b)
Error in eval(expr, envir, enclos) (from #3) : object 'cutoff' not found
We can fix this with a simple C function:
SEXP top_prenv(SEXP nm, SEXP env)
{
SEXP promise = findVar(nm, env);
while(TYPEOF(promise) == PROMSXP) {
env = PRENV(promise);
promise = PREXPR(promise);
}
return env;
}
With R wrapper:
top_prenv <- function(x) {
.Call2("top_prenv", substitute(x), parent.frame())
}
Then this works (need to set subset,B again to reset cache):...
2016 Sep 17
2
Handlers in setGraphicsEventHandlers() can recursively call getGraphicsEvent(). Intended behavior?
...=====================================================
--- src/main/gevents.c (revision 71293)
+++ src/main/gevents.c (working copy)
@@ -211,8 +211,6 @@
int i;
SEXP handler, bvec, sx, sy, temp, result;
- dd->gettingEvent = FALSE; /* avoid recursive calls */
-
PROTECT(handler = findVar(install(mouseHandlers[event]), dd->eventEnv));
if (TYPEOF(handler) == PROMSXP) {
handler = eval(handler, dd->eventEnv);
@@ -242,7 +240,7 @@
R_FlushConsole();
}
UNPROTECT(1); /* handler */
- dd->gettingEvent = TRUE;
+
return;
}
@@ -257,8 +255,6 @@
{
SEXP...
2003 May 28
0
R_GlobalEnv
...v. Can anyone tell me why?
[ My motivation is that I want use defineVar to initialise a
workingEnvironment (corresponding to Value below), so that event-handler
functions for a specific C library (which must have a specific
prototype) can call R functions by looking up workingEnvironment with
findVar. Earlier, I tried a static global SEXP variable in C to
keep track of the environment, but that's not reliable because
of garbage collection. Maybe SEXPREC would work better? ]
Thanks in advance,
James
***** testR_GlobalEnv.c *****
#include <R.h>
#include <Rinternals.h>
#includ...
2001 Apr 25
0
match.arg confusion (PR#921)
...ys.function has to grab the call, take the 1st element,
and reevaluate it in the parent frame. It is quite easy to think up
examples where a second evaluation does not give the same value as
the first.
Your particular case is of a slightly different natur and should be
easily fixable by replacing findVar in R_sysfunction by findVar1 and
looking specifically for objects of mode "function", but the basic
problem persists. I don't think I want to risk fixing this (and maybe
unfixing something else) for 1.2.3 tomorrow though.
--
O__ ---- Peter Dalgaard Blegdamsvej 3...
2006 Mar 29
0
substitute() bug by you ? [forwarded]
...n coerce.c :
Thanks, I was just coming to the same conclusion. I'll look into it.
Duncan
>
> ----------------------------------------------------------------------------
> r37269 | murdoch | 2006-02-05 18:00:54 +0100 (Sun, 05 Feb 2006) | 7 lines
>
> Changes to substitute and findVar:
> In C, substitute( , R_NilValue) does no substs, just
> getting PREXPRs, while substitute( , R_GlobalEnv) does
> substitutions.
>
> In R: substitute( , .GlobalEnv) is just like
> R_NilValue above, as is substitute( , NULL).
> ------------------------------------------------...
2008 Jul 18
0
Rcpp from C++
...around and finds the data to an R variable name:
SEXP getVar(SEXP name, SEXP rho)
{
SEXP ans;
if(!isString(name) || length(name) != 1)
error("name is not a single string");
if(!isEnvironment(rho))
error("rho should be an environment");
ans = findVar(install(CHAR(STRING_ELT(name, 0))), rho);
return ans;
}
To get the data of an R-variable you should be able to use the constructors
from Rcpp that take an SEXP as argument, but i also haven't tried that yet.
What I found to be useful too is the routine for evaluating R-commands:...
2012 Jul 02
0
[klibc:master] [SHELL] Allow building without LINEO support
...ef WITH_LINENO
{ 0, VSTRFIXED|VTEXTFIXED, linenovar, 0 },
+#endif
#ifndef SMALL
{ 0, VSTRFIXED|VTEXTFIXED|VUNSET, "TERM\0", 0 },
{ 0, VSTRFIXED|VTEXTFIXED|VUNSET, "HISTSIZE\0", sethistsize },
@@ -335,9 +337,11 @@ lookupvar(const char *name)
struct var *v;
if ((v = *findvar(hashvar(name), name)) && !(v->flags & VUNSET)) {
+#ifdef WITH_LINENO
if (v == &vlineno && v->text == linenovar) {
fmtstr(linenovar+7, sizeof(linenovar)-7, "%d", lineno);
}
+#endif
return strchrnul(v->text, '=') + 1;
}
return NULL;...
2007 Sep 20
1
copying promise
1. Is there some way to copy a promise so that the copy has the same
expression in its promise as the original. In the following we
y is a promise that we want to copy to z. We
want z to be a promise based on the expression x since y is a
promise based on the expression x. Thus the answer to the code
below is desired to be z=2 but its 1, 1 and y in the next three
examples so they are not the