similar to: `eval' and environment question

Displaying 20 results from an estimated 10000 matches similar to: "`eval' and environment question"

2007 Nov 12
2
strange `nls' behaviour
I initially thought, this should better be posted to r-devel but alas! no response. so I try it here. sory for the lengthy explanation but it seems unavoidable. to quickly see the problem simply copy the litte example below and execute f(n=5) which crashes. called with n != 5 (and of course n>3 since there are 3 parameters in the model...) everything is as it should be. in detail:
2011 Nov 24
1
capture.output(eval(..., envir)) not evaluate in the expected(?) environment
I've noticed the following oddity where capture.output() prevents eval() from evaluating an expression in the specified environment. I'm not sure if it is an undocumented feature or a bug. It caused me many hours of troubleshooting. By posting it here, it might save someone else from doing the same exercise. Start by defining foo() which evaluates an expression locally in a given
2008 Jul 29
1
environment question
Hi R users! I was looking at some of the example code for the "environment" function. Here it is: e1 <- new.env(parent = baseenv()) # this one has enclosure package:base. e2 <- new.env(parent = e1) assign("a", 3, envir=e1) ls(e1) ls(e2) exists("a", envir=e2) # this succeeds by inheritance exists("a", envir=e2, inherits = FALSE)
2012 Sep 02
1
glmulti runs indefinitely when using genetic algorithm with lme4
Dear List, I'm using glmulti for model averaging in R. There are ~10 variables in my model, making exhaustive screening impractical - I therefore need to use the genetic algorithm (GA) (call: method = "g"). I need to include random effects so I'm using glmulti as a wrapper for lme4. Methods for doing this are available here
2006 Apr 04
2
Return function from function with minimal environment
Hi, this relates to the question "How to set a former environment?" asked yesterday. What is the best way to to return a function with a minimal environment from a function? Here is a dummy example: foo <- function(huge) { scale <- mean(huge) function(x) { scale * x } } fcn <- foo(1:10e5) The problem with this approach is that the environment of 'fcn' does not
2012 May 15
1
Error in eval(expr, envir, enclos) : object 'Rayos' not found???
Hi R-listers, I am trying to make a trellis boxplot with the HSuccess (y-axis) in each Rayos (beach sections) (x-axis), for each Aeventexhumed (A, B, C) - nesting event. I am not able to do so and keep receiving: Error in eval(expr, envir, enclos) : object 'Rayos' not found Please advise, Jean require(plyr) resp <- read.csv("ABC Arribada R File Dec 12 Jean
2009 Jan 05
2
eval using a environment X but resultsin .GlobalEnv
Hello, Suppose I have an expression, E, which accesses some variables present in an environment V. I do this via eval(E,envir=V) however all assignments end up in V. I would like the results of assignments in E to end up in the .GlobalEnv ? Or at least the calling environment. Is there a quick way to this instead of iterating over all objects E and assigning into .GlobalEnv? Thank you Saptarshi
2005 May 14
2
help with eval
I've been looking at the help page for eval for a while, but I can't make sense of why this example does not work. show.a <- function() { a } init.env <- function() { a <- 200 environment() } my.env <- init.env() ls(envir=my.env) # returns this: # > ls(envir=my.env) # [1] "a" # but this does not work: eval(expression(show.a()),envir=my.env) # >
2011 Mar 11
1
dataframe to a timeseries object
I?m wondering which is the most efficient (time, than memory usage) way to obtain a multivariate time series object from a data frame (the easiest data structure to get data from a database trough RODBC). I have a starting point using timeSeries or xts library (these libraries can handle time zones), below you can find code to test. Merging parallelization (cbind) is something I?m thinking at
2015 Feb 09
1
WISH: eval() to preserve the "visibility" (now value is always visible)
Sorry to intervene. Argument passed to 'eval' is evaluated first. So, eval(x <- 2) is effectively like { x <- 2; eval(2) } , which is effectively { x <- 2; 2 } . The result is visible. eval(expression(x <- 2)) or eval(quote(x <- 2)) or evalq(x <- 2) gives the same effect as x <- 2 . The result is invisible. In function 'eval2', res <-
2005 Nov 18
2
about eval and eval.parent
x<-1 f<-function(){ x<-3 eval(substitute(x+y,list(y=10))) } f() #13 x<-1 f<-function(){ x<-3 eval(substitute(x+y,list(y=10)), envir = sys.frame(sys.parent())) } f() #11 x<-1 f<-function(){ x<-3 eval.parent(substitute(x+y,list(y=10))) } f()#11 the help page says: "If 'envir' is not specified, then 'sys.frame(sys.parent())', the
2015 Feb 07
1
WISH: eval() to preserve the "visibility" (now value is always visible)
Would it be possible to have the value of eval() preserve the "visibility" of the value of the expression? "PROBLEM": # Invisible > x <- 1 # Visible > eval(x <- 2) [1] 2 "TROUBLESHOOTING": > withVisible(x <- 1) $value [1] 1 $visible [1] FALSE > withVisible(eval(x <- 2)) $value [1] 2 $visible [1] TRUE WORKAROUND: eval2 <-
2010 Sep 21
3
Error in eval(expr, envir, enclos)
I am absolutely new to R and I am aware of only a few basic command lines. I was running a robust regression in R, using the following command line library (MASS) rfdmodel1 <- rlm (TotalEmployment_2004 ~ MISSISSIPPI + LOUISIANA + TotalEmployment_2000 + PCWhitePop_2004 + UnemploymentRate_2004 + PCUrbanPop2000 + PCPeopleWithACollegeDegree_2000 + PCPopulation.of.or.over.65.years.of.age_2004)
2011 Mar 23
2
) Error in eval(expr, envir, enclos) : object '' not found
> datafilename="E:/my documents/r/sex/bysex1.csv" > data.sex=read.table(datafilename,header=T) > data.sex y.sex.age.region.c.n 1 1980,F,A,N,-18.15,13.61 2 1980,F,A,N,-18.61,13.04 3 1980,F,A,N,-18.81,12.32 4 1990,F,A,N,-21.12,11.7 5 1990,F,A,N,-20.77,11.58 6 1990,F,A,N,-21.6,13.34 7 1990,F,A,N,-21.78,12.6 > model.anova<-aov(c~age*sex,data=data.sex)
2002 Sep 04
3
strange things with eval and parent frames
Dear mailing list, I have found some strange behaviour which I think relates to parent frames and eval. Can anyone explain what's going on here? First example: > test.parent.funcs_ function() { outer.var_ 5 subfunc1_ function() substitute( outer.var, envir=parent.frame()) print( subfunc1()) subfunc2b_ function() eval( quote( outer.var), envir=parent.frame()) print(
2007 Jun 07
1
MITOOLS: Error in eval(expr, envir, enclos) : invalid 'envir' argument
R-users & helpers: I am using Amelia, mitools and cmprsk to fit cumulative incidence curves to multiply imputed datasets. The error message that I get "Error in eval(expr, envir, enclos) : invalid 'envir' argument" occurs when I try to fit models to the 50 imputed datasets using the "with.imputationList" function of mitools. The problem seems to occur
2005 Feb 17
1
Error in eval(expr, envir, enclos) : numeric envir arg not of length one
I am working with a largish dataset of 25k lines and I am now tying to use predict. pred = predict(cuDataGlmModel, length + meanPitch + minimumPitch + maximumPitch + meanF1 + meanF2 + meanF3 + meanF4 + meanF5 + ratioF1ToF2 + rationF3ToF1 + jitter + shimmer + percentUnvoicedFrames + numberOfVoiceBreaks + percentOfVoiceBreaks + meanIntensity + minimumIntensity + maximumIntensity +
2010 Mar 30
3
From THE R BOOK -> Warning: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!
Dear friends, I am testing glm as at page 514/515 of THE R BOOK by M.Crawley, that is on proportion data. I use glm(y~x1+,family=binomial) y is a proportion in (0,1), and x is a real number. I get the error: In eval(expr, envir, enclos) : non-integer #successes in a binomial glm! But that is exactly what was suggested in the book, where there is no mention of a similar warning. Where am I
2004 Nov 25
1
eval in correct frame?
I am trying, without success, to find out how to formulate correctly the parameters of "eval". My code snippet looks like: proutside <- function(txt) { cat("\n",txt,"\n"); print(eval(parse(text = txt))) } vari <- function(Ob) { prininside <- function(txt) { cat("\n",txt,"\n"); print(eval(parse(text = txt))) }
2001 Jul 19
1
bug in eval
Is this a bug ? > foo <- function(a, ...) + { + tl <- substitute(list(a=a)) + + ## the foll two should give the same results + ## according to defaults for eval + + print(eval(tl )) + print(eval(tl, parent.frame())) + } > > > foo1 <- function(...) + { + foo(...) + } > > test <- function(a = 6) + { + foo1(a = a) + } > >