search for: baseenv

Displaying 20 results from an estimated 86 matches for "baseenv".

Did you mean: basedn
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 no...
2010 Feb 25
2
proto and baseenv()
...roto 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 parent definitions have already been the source of bizarre bugs, prompting me to use proto like this: > z <- 1 > y <- proto(baseenv(), a=2) > y$z Error in get(x, env = this, inherits = inh) : object 'z' not found It...
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 afte...
2005 Nov 04
1
Changes to environments in R-devel
I've just committed some changes to R-devel which affect environments. Specifically: - using NULL as an environment is now deprecated: use baseenv() instead. (baseenv() is already available in R 2.2.0, where it returns NULL. For most purposes it retains the same meaning in R-devel.) If you do use NULL, it will be converted to baseenv(), and a warning printed. For example: > f <- function(x) 1 > environment(f) <- NULL Warn...
2006 Apr 04
2
Return function from function with minimal environment
...<- environment(fcn) save(env, file="temp.RData"); file.info("temp.RData")$size # [1] 2007720 When I try to set the parent environment of 'env' to emptyenv(), it does not work, e.g. fcn(2) # Error in fcn(2) : attempt to apply non-function but with the new.env(parent=baseenv()) it works fine. The "base" environment has the empty environment as a parent. So, I try to do the same myself, i.e. new.env(parent=new.env(parent=emptyenv())), but once again I get fcn(2) # Error in fcn(2) : attempt to apply non-function Apparently, I do not understand enough here....
2011 Mar 11
1
dataframe to a timeseries object
...envir = env) else assign("xx", timeSeries(x$VALUE, x$DATE, format = '%Y-%m-%d %H:%M:%S', zone = 'GMT', units = as.character(x$ID[1])), envir = env) return(TRUE) } } fooBy <- function(...) { e1 <- new.env(parent = baseenv()) res <- by(X, X$ID, buildTimeSeriesFromDataFrame, env = e1, simplify = TRUE) return(get("xx", e1)) } Time01 <- replicate(100, system.time(fooBy(X, X$ID, buildTimeSeriesFromDataFrame, simplify = TRUE))[[1]]) median(Time01) hist(Time01) library(xts) buildXtsF...
2018 Dec 21
2
Bug report: R.home() cause package Rcpp failed executing sourceCpp, similar bug are labeled "BUG 16660" since 2016 and here I could provide a solution that tested in my laptop.
...!showOutput) : 'D:/Program' not found Error in system(cmd, ignore.stderr = TRUE, intern = TRUE) : 'D:/Program' not found Code is tested in both R 3.5.1 and Microsoft R Open 3.5.1. I find a temp solution, is to copy such words into Rprofile: unlockBinding("R.home", baseenv()) utils::assignInNamespace("R.home",function (component = "home") { rh <- .Internal(R.home()) paste0('"',switch(component, home = rh, bin = if (.Platform$OS.type == "windows" && nzchar(p <- .Platform$r_arch)) file.path(rh,...
2020 Aug 10
3
lm() takes weights from formula environment
...how other values are treated." But I did not. So I do apologize for both that and for negative tone on my part. Simplified example: d <- data.frame(x = 1:3, y = c(1, 2, 1)) w <- c(1, 10, 1) f <- as.formula(y ~ x) lm(f, data = d, weights = w) # works # fails environment(f) <- baseenv() lm(f, data = d, weights = w) # Error in eval(extras, data, env) : object 'w' not found > On Aug 9, 2020, at 11:56 AM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote: > > This is fairly clearly documented in ?lm: >
2018 Mar 06
4
Capturing warning within user-defined function
...roup4"))) dta <- data.frame(grp, wt) head(dta) str(dta) # declare design my.svy <- svydesign(ids=~1, weights=~wt, data=dta) # subset grp1 <- subset(my.svy, grp == "Group1") # set options and clear old warnings options(warn=0) assign("last.warning", NULL, envir = baseenv()) ## proportions and CIs p <- ((svyciprop(~grp, grp1, family=quasibinomial))[1]) # save warnings wrn1 <- warnings(p) ci_l <- (confint(svyciprop(~grp, grp1, family=quasibinomial), 'ci')[1]) ci_u <- (confint(svyciprop(~grp, grp1, family=quasibinomial), 'ci')[2]) ## sa...
2020 Jun 30
4
R-devel internal errors during check produce?
...>> 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 >> error >> env_list <- list(baseenv(), >> as.environment("package:graphics"), >> as.environment("package:stats"), >> as.environment("package:utils"), >> as.environment("package:methods") ) >> unique(env_list) > Thanks ... but th...
2020 Aug 10
1
lm() takes weights from formula environment
...thing in the middle or at the end (because the chain ends with emptyenv(), which is not allowed to have a parent). > > So I'd suggest using > > environment(f) <- environment() > > before calling lm() if you want the calling environment to be in the search. Setting it to baseenv() doesn't really make sense, unless you want to disable all searches except in data, in which case emptyenv() would make more sense (but I haven't tried it, so it might break something). > > Duncan Murdoch > >> But I did not. So I do apologize for both that and for negative...
2006 Nov 03
1
data.entry(), de() fail in FC6-x86_64
...39;demo()' para demonstra??es, 'help()' para o sistema on-line de ajuda, ou 'help.start()' para abrir o sistema de ajuda em HTML no seu navegador. Digite 'q()' para sair do R. Loading Tcl/Tk interface ... done [?rea de trabalho anterior carregada] > if(!exists("baseenv", mode="function")) baseenv <- function() NULL options(STERM='iESS', editor='emacsclient') > > > > c <- c(1,2,3,4) > de(c) *** buffer overflow detected ***: /usr/lib64/R/bin/exec/R terminated ======= Backtrace: ========= /lib64/libc.so.6(__chk_f...
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) exists("+", envir=e2) # this succeeds by inheritan...
2007 May 15
1
getNamespaceExports("base") error
...(ns) { ns <- asNamespace(ns) if (isBaseNamespace(ns)) ls(NULL, all = TRUE) else ls(getNamespaceInfo(ns, "exports"), all = TRUE) } <environment: namespace:base> One possible way to fix this could be to changed to e.g. if (isBaseNamespace(ns)) ls(envir=baseenv(), all = TRUE) Observed with R 2.5.0 & R 2.6.0 devel (2007-05-12 r41546) (one has to go back to R 2.3.1 to see it working) Regards, Matthias -- Matthias Burger Project Manager/ Biostatistician Epigenomics AG Kleine Praesidentenstr. 1 10178 Berlin, Germany p...
2013 Feb 22
2
Fitting this data with a gaussian would be great
...832,510184,511272,513380,515828,519160,525046,534046,547982,567124,590208,614506,637876,656846,669054,672976,668800,656070,637136,614342,590970,570752,554480,542882,535630,531276,528682,527682,527020,526834,526802,526860) test <- glm(dnorm(x), data=small) Error in formula.default(object, env = baseenv()) : invalid formula I have tried a variety of options for the formula with the same effect. What I want to do with this data is simply fit it with a non linear model, most likely a gaussian. Thanks in advance, Samantha [[alternative HTML version deleted]]
2007 Jan 09
4
A question about R environment
Hi all, I created environment "mytoolbox" by : mytoolbox <- new.env(parent=baseenv()) Is there anyway I put it in the search path ? If you need some background : In a project, I often write some small functions, and load them into my workspace directly, so when I list the objects with ls(), it looks pretty messy. So I am wondering if it is possible to creat an envir...
2018 Mar 06
0
Capturing warning within user-defined function
...a) > str(dta) > > # declare design > my.svy <- svydesign(ids=~1, weights=~wt, data=dta) > > # subset > grp1 <- subset(my.svy, grp == "Group1") > > # set options and clear old warnings > options(warn=0) > assign("last.warning", NULL, envir = baseenv()) > > ## proportions and CIs > p <- ((svyciprop(~grp, grp1, family=quasibinomial))[1]) > > # save warnings > wrn1 <- warnings(p) > > ci_l <- (confint(svyciprop(~grp, grp1, family=quasibinomial), 'ci')[1]) > ci_u <- (confint(svyciprop(~grp, grp1, famil...
2018 Mar 06
0
Capturing warning within user-defined function
...a) > str(dta) > > # declare design > my.svy <- svydesign(ids=~1, weights=~wt, data=dta) > > # subset > grp1 <- subset(my.svy, grp == "Group1") > > # set options and clear old warnings > options(warn=0) > assign("last.warning", NULL, envir = baseenv()) > > ## proportions and CIs > p <- ((svyciprop(~grp, grp1, family=quasibinomial))[1]) > > # save warnings > wrn1 <- warnings(p) > > ci_l <- (confint(svyciprop(~grp, grp1, family=quasibinomial), 'ci')[1]) > ci_u <- (confint(svyciprop(~grp, grp1, famil...
2018 Mar 06
1
Capturing warning within user-defined function
...ign > > my.svy <- svydesign(ids=~1, weights=~wt, data=dta) > > > > # subset > > grp1 <- subset(my.svy, grp == "Group1") > > > > # set options and clear old warnings > > options(warn=0) > > assign("last.warning", NULL, envir = baseenv()) > > > > ## proportions and CIs > > p <- ((svyciprop(~grp, grp1, family=quasibinomial))[1]) > > > > # save warnings > > wrn1 <- warnings(p) > > > > ci_l <- (confint(svyciprop(~grp, grp1, family=quasibinomial), 'ci')[1]) > > ci...
2016 May 20
2
identical on closures
I'm confused by this: > identical(function() {}, function() {}) [1] FALSE Yet, after loading the Matrix package (which redefines det), the following is checked (in library.checkConflicts): > identical(get("det", baseenv()), get("det", asNamespace("Matrix")), ignore.environment=T) [1] TRUE I've looked at the code in identical.c and for closures it seems to compare the FORMALS and the BODY_EXPR, so why does the first example not return TRUE as surely the formals and body are identical?...