similar to: Environment with no parent?

Displaying 20 results from an estimated 10000 matches similar to: "Environment with no parent?"

2015 Oct 13
1
A where() functions that does what exists() does but return the environment when object lives?
On Tue, Oct 13, 2015 at 4:43 PM, Hadley Wickham <h.wickham at gmail.com> wrote: > Seems easy enough to write yourself: > > where <- function(x, env = parent.frame()) { > if (identical(env, emptyenv())) > return(NULL) > if (exists(x, envir = env, inherits = FALSE)) > return(env) > where(x, parent.env(env)) > } > > sample2 <-
2008 May 10
2
Hashes as S4 Classes, or: How to separate environments
For learning purposes mainly I attempted to implement hashes/maps/dictionaries (Python lingua) as S4 classes, see the coding below. I came across some rough S4 edges, but in the end it worked (for one dictionary). When testing ones sees that the dictionaries D1 and D2 share their environments D1 at hash and D2 at hash, though I thought a new and empty environment would be generated each time
2013 Apr 18
2
how to control the environment of a formula
Dear List I have experienced that objects generated with one of my packages used a lot of space when saved on disc (object.size did not show this!). some debugging revealed that formula and call objects carried the full environment of subroutines along, including even stuff not needed by the formula or call. here is a sketch of the problem ,---- | test <- function(x){ | x <-
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
2019 Aug 15
1
Rf_defineVar(symbol, R_UnboundValue, environment) questions
While poking around the C++ code in the dplyr package I ran across the idiom Rf_defineVar(symbol, R_UnboundValue, environment) to [sort of] remove 'symbol' from 'environment' Using it makes the R-level functions objects(), exists(), and get() somewhat inconsistent and I was wondering if that was intended. E.g., use SHLIB to make something from the following C code that
2019 Mar 23
4
topenv of emptyenv
I was surprised just now to find out that `topenv(emptyenv())` equals ? `.GlobalEnv`, not `emptyenv()`. From my understanding of the description of `topenv`, it should walk up the chain of enclosing environments (as if by calling `e = parent.env(e)` repeatedly; in fact, that is almost exactly its implementation in envir.c) until it hits a top level. However, `emptyenv()` has no enclosing
2009 Jun 02
2
formal argument "envir" matched by multiple actual arguments
Hi list, This looks similar to the problem reported here https://stat.ethz.ch/pipermail/r-devel/2006-April/037199.html by Henrik Bengtsson a long time ago. It is very sporadic and non-reproducible. Henrik, do you remember if your code was using reg.finalizer()? I tend to suspect it but I'm not sure. I've been hunting this bug for months but today, and we the help of other Bioconductor
2011 Mar 17
1
assigning to list element within target environment
I would like to assign an value to an element of a list contained in an environment. The list will contain vectors and matrices. Here's a simple example: # create toy environment testEnv = new.env(parent = emptyenv()) # create list that will be in the environment, then assign() it x = list(a=1,b=2) assign("xList",x,testEnv) # create new element, to be inserted into xList c = 5:7
2010 Nov 06
1
Hashing and environments
Hi, I'm trying to write a general-purpose "lexicon" class and associated methods for storing and accessing information about large numbers of specific words (e.g., their frequencies in different genres). Crucial to making such a class practically useful is to get hashing working correctly so that information about specific words can be accessed quickly. But I've never really
2011 Jun 09
2
Coercing Output from mget() into Proper Data Frame
Hello R-philes: I have the following function that gets the output of mget() and converts it to a data frame to return. What I am finding is that the dimensions are wrong. Basically, I get: bridesmaid wed u see m gt lt like love X.0 dress pagetrack one go X3 get 1 56 35 27 30 24 20 20 23 28 17 25 16 16 28 15 26 Instead, I want something like: [1] bridesmaid
2016 Aug 05
2
Extra copies of objects in environments when using $ operator?
My understanding is that R will not make copies of lists if there is only one reference to the object. However, I've encountered a case where R does make copies, even though (I think) there should be only one reference to the object. I hope that someone could shed some light on why this is happening. I'll start with a simple example. Below, x is a list with one element, and changing that
2017 May 11
0
R-3.3.3/R-3.4.0 change in sys.call(sys.parent())
On Wed, May 10, 2017 at 2:36 AM, William Dunlap via R-devel <r-devel at r-project.org> wrote: > Some formula methods for S3 generic functions use the idiom > returnValue$call <- sys.call(sys.parent()) > to show how to recreate the returned object or to use as a label on a > plot. It is often followed by > returnValue$call[[1]] <- quote(myName) > E.g., I see
2011 Jan 11
1
as.environment.list provides inconsistent results under torture
Hello, Using R-devel (rev 53950), I get inconsistent results with as.environment( VECSXP ) when gctorture is on. Consider: a <- list( aa = rnorm, bb = runif ) gctorture(TRUE) as.environment( a ) The last line sometimes produces the correct environment, but sometimes I get errors. Here are the three situations: # good > as.environment( a ) <environment: 0x100b1c978> # not good
2020 Aug 10
1
lm() takes weights from formula environment
Thank you for your suggestion. I do know how to work around the issue. I usually build a fresh environment as a child of base-environment and then insurt the weights there. I was just trying to provide an example of the issue. emptyenv() can not be used, as it is needed for the eval (errors out even if weights are not used with "could not find function list"). For some applications
2017 May 11
1
R-3.3.3/R-3.4.0 change in sys.call(sys.parent())
Here is a case where the current scheme fails: > with(datasets::mtcars, xyplot(mpg~wt|gear)$call) xyplot(substitute(expr), data, enclos = parent.frame()) Bill Dunlap TIBCO Software wdunlap tibco.com On Thu, May 11, 2017 at 1:09 AM, Deepayan Sarkar <deepayan.sarkar at gmail.com> wrote: > On Wed, May 10, 2017 at 2:36 AM, William Dunlap via R-devel > <r-devel at
2015 Oct 13
0
A where() functions that does what exists() does but return the environment when object lives?
Seems easy enough to write yourself: where <- function(x, env = parent.frame()) { if (identical(env, emptyenv())) return(NULL) if (exists(x, envir = env, inherits = FALSE)) return(env) where(x, parent.env(env)) } sample2 <- base::sample where("sample2") #> <environment: 0x1154d3c28> where("sample") #> <environment: base>
2015 Oct 09
4
A where() functions that does what exists() does but return the environment when object lives?
Hi, exists("foo", inherits=TRUE) check whether an object named "foo" exists, and get("foo", inherits=TRUE) retrieves it. I'm looking for a similar function to exists() that returns the environment where the object "foo" exists, iff at all. If not found, NULL is returned. Does that exist? EXAMPLE #1: > sample2 <- base::sample > env <-
2020 Aug 10
3
lm() takes weights from formula environment
I wish I had started with "I am disappointed that lm() doesn't continue its search for weights into the calling environment" or "the fact that lm() looks only in the formula environment and data frame for weights doesn't seem consistent with how other values are treated." But I did not. So I do apologize for both that and for negative tone on my part. Simplified
2019 Mar 28
0
topenv of emptyenv
>>>>> Konrad Rudolph >>>>> on Sat, 23 Mar 2019 14:26:40 +0000 writes: >>>>> Konrad Rudolph >>>>> on Sat, 23 Mar 2019 14:26:40 +0000 writes: > I was surprised just now to find out that `topenv(emptyenv())` equals > ? `.GlobalEnv`, not `emptyenv()`. From my understanding of the > description of `topenv`, it
2010 Sep 01
2
testing for emptyenv
Dear R-users, Is there a way to test whether a particular environment e is equal to emtyenv(), or for that sake whether two environments e1 and e2 are equal? I tried a couple of ways to compare environments, but neither seem to work: > e1 <- new.env() > e2 <- new.env() > e1 == e2 Error in e1 == e2 : comparison (1) is possible only for atomic and list types > all.equal(e1,