Displaying 20 results from an estimated 40000 matches similar to: "Changes to environments in R-devel"
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
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
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
2006 Apr 25
7
R 2.3.0: Use of NULL as an environment is deprecated
Dear R-Devel subscriber,
first, let me express my thank to the R-Core team for the new release! I
appreciate their efforts and time spent to enhance R.
In accordance with the 'NEWS' file (see excerpt of it below),
[...
o Changed the environment tree to be rooted in an empty
environment, available as emptyenv(). baseenv() has been
modified to return an environment with emptyenv() as
2006 Apr 25
7
R 2.3.0: Use of NULL as an environment is deprecated
Dear R-Devel subscriber,
first, let me express my thank to the R-Core team for the new release! I
appreciate their efforts and time spent to enhance R.
In accordance with the 'NEWS' file (see excerpt of it below),
[...
o Changed the environment tree to be rooted in an empty
environment, available as emptyenv(). baseenv() has been
modified to return an environment with emptyenv() as
2010 Feb 25
2
proto and baseenv()
I understand why the following happens ($.proto delegates to get,
which ascends the parent hierarchy up to globalenv()), but I still
find it anti-intuitive:
> z <- 1
> y <- proto(a=2)
> y$z
[1] 1
Although this is well-documented behavior; wouldn't it uphold the
principle of least surprise to inherit instead from baseenv() or
emptyenv()? (See attached patch.)
Spurious
2020 Aug 10
0
lm() takes weights from formula environment
On 10/08/2020 1:42 p.m., John Mount wrote:
> 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."
Normally searching is done automatically by
2014 Sep 21
1
Bug in new behaviour for all.equal and environments?
Hi R-devel,
The following code:
all.equal(baseenv(), baseenv())
gives the error when run in a clean R session with latest R-devel (r66650):
kevin:~$ R --vanilla --slave -e "all.equal(baseenv(), baseenv())"
Error in all.equal.envRefClass(target[[i]], current[[i]],
check.attributes = check.attributes, :
attempt to apply non-function
Calls: all.equal ...
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 11
1
eapply() fails on baseenv() (PR#8761)
eapply() works on most environments, but not on baseenv(). For example,
> x <- 1
> eapply(globalenv(), function(x) x)
$x
[1] 1
> eapply(baseenv(), function(x) x)
list()
I'm probably not going to have time to work on this before 2.3.0, but I
don't think it's really urgent; if no one else fixes it first I'll do it
after the release.
Duncan Murdoch
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)
2007 Sep 04
1
Variable scope in a function
Hello,
I apologise in advance for this question; I'm sure it is answered in
the documentation or this mailing list many times, however the answer
has eluded me.
I'm trying to write a function where I don't want external variables
to be scoped in from the parent environment. Given this function:
test_func = function() {
if (exists("kat") == FALSE) {
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
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
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
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,
2005 Feb 08
1
Environment with no parent?
Is it possible to create an environment that has no parent (or an
empty parent)? I would have thought
e <- new.env(parent=NULL)
would work, but it acts as though the parent is the base namespace:
> get("close", envir = e)
function (con, ...)
UseMethod("close")
<environment: namespace:base>
I can use inherits = FALSE in this case:
> get("close",
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
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 <-
2020 Jun 30
4
R-devel internal errors during check produce?
>>>>> Kurt Hornik
>>>>> on Tue, 30 Jun 2020 06:20:57 +0200 writes:
>>>>> Jan Gorecki writes:
>> Thank you both, You are absolutely correct that example
>> should be minimal, so here it is.
>> l = list(a=new.env(), b=new.env()) unique(l)
>> Just for completeness, env_list during check that raises