Re: [Rd] identical(..., ignore.environment=TRUE)

2015-10-13 Thread Martin Maechler
> Duncan Murdoch > on Mon, 12 Oct 2015 19:31:11 -0400 writes: > On 12/10/2015 9:51 AM, Ben Bolker wrote: >> Duncan Murdoch gmail.com> writes: >> BB> > It seems odd/inconvenient to me that the > "ignore.environment" argument of identical() only >>

Re: [Rd] identical(..., ignore.environment=TRUE)

2015-10-13 Thread William Dunlap
MM> but I don't think we'd want to MM> change all.equal.language() at this point in time Although it would be nice if all.equal looked at least at attributes of formulas so we did not get results like > form <- y ~ x1 %in% x2 > all.equal(form, terms(form)) [1] TRUE > all.equal(terms(y~x1

Re: [Rd] identical(..., ignore.environment=TRUE)

2015-10-13 Thread Martin Maechler
> William Dunlap > on Tue, 13 Oct 2015 09:12:34 -0700 writes: > MM> but I don't think we'd want to > MM> change all.equal.language() at this point in time > Although it would be nice if all.equal looked at least at attributes of > formulas > so we did not get results like > > f

Re: [Rd] A where() functions that does what exists() does but return the environment when object lives?

2015-10-13 Thread Henrik Bengtsson
On Sat, Oct 10, 2015 at 1:24 AM, Uwe Ligges wrote: > I'd start looking at getAnywhere(). Thanks Uwe, that does indeed provides "where" information. Unfortunately, I don't see how it will allow me to search environments similarly/in the same order as exists/get(..., envir, inherits=TRUE) does it.

Re: [Rd] A where() functions that does what exists() does but return the environment when object lives?

2015-10-13 Thread Hadley Wickham
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") #> where("samp

Re: [Rd] A where() functions that does what exists() does but return the environment when object lives?

2015-10-13 Thread Hadley Wickham
On Tue, Oct 13, 2015 at 4:43 PM, Hadley Wickham 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, paren

Re: [Rd] A where() functions that does what exists() does but return the environment when object lives?

2015-10-13 Thread Uwe Ligges
On 13.10.2015 22:39, Henrik Bengtsson wrote: On Sat, Oct 10, 2015 at 1:24 AM, Uwe Ligges wrote: I'd start looking at getAnywhere(). Thanks Uwe, that does indeed provides "where" information. Unfortunately, I don't see how it will allow me to search environments similarly/in the same order a

Re: [Rd] A where() functions that does what exists() does but return the environment when object lives?

2015-10-13 Thread Henrik Bengtsson
Thanks Uwe and thanks Hadley. I ended up implementing: ## Emulates R internal findVar1mode() function ## https://svn.r-project.org/R/trunk/src/main/envir.c where <- function(x, where=-1, envir=if (missing(frame)) { if (where < 0) parent.frame(-where) else as.environment(where) } else sys.frame(fr