search for: list2env

Displaying 20 results from an estimated 56 matches for "list2env".

2015 Jul 15
2
bquote/evalq behavior changed in R-3.2.1
...n expression-object rather than a call-object seemed to solve the problem when this was posed as a question on StackOverflow, but Dayne was not happy with that solution for other reasons that he is not describing. -- David. > In R-3.1.3 we got > rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > #[1] 18 > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > #Error in (function (expr, envir = parent.frame(), enclos = if > (is.list(envir) || : > object 'myNumber' not found > lapply(list(quote(1+myNumber)), evalq, envir=l...
2015 Jul 15
2
bquote/evalq behavior changed in R-3.2.1
...blem when this was posed as a question on StackOverflow, but Dayne was >> not happy with that solution for other reasons that he is not describing. >> >> -- >> David. >> >> > In R-3.1.3 we got >> > rapply(list(quote(1+myNumber)), evalq, >> envir=list2env(list(myNumber=17))) >> > #[1] 18 >> > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) >> > #Error in (function (expr, envir = parent.frame(), enclos = if >> > (is.list(envir) || : >> > object 'myNumber' not found >&g...
2015 Jul 15
3
bquote/evalq behavior changed in R-3.2.1
In 3.1.2 eval does not store the result of the bquote-generated call in the given environment. Interestingly, in 3.2.1 eval does store the result of the bquote-generated call in the given environment. In other words if I run the given example with eval rather than evalq, on 3.1.2 "x" is never stored in "fenv," but it is when I run the same code on 3.2.1. However, the given
2015 Jul 15
0
bquote/evalq behavior changed in R-3.2.1
I think rapply() was changed to act like lapply() in this respect. In R-3.1.3 we got rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) #[1] 18 rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) #Error in (function (expr, envir = parent.frame(), enclos = if (is.list(envir) || : object 'myNumber' not found lapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) #...
2010 Oct 29
1
list2env() is broken
Hi, The following code produces different kinds of problems depending on which platform you run it: x <- as.list(1:200000) names(x) <- paste("A", 1:200000, sep="") e <- list2env(x) Timeout on Linux, crash on Mac and Windows, with R 2.12.0 and current R devel. The "multi-assign" mode (i.e. when the 'envir' arg is supplied) doesn't seem to have this problem. Cheers, H. -- Herv? Pag?s Program in Computational Biology Division of Public Health Scien...
2015 Jul 15
0
bquote/evalq behavior changed in R-3.2.1
...l-object seemed to solve the problem > when this was posed as a question on StackOverflow, but Dayne was not happy > with that solution for other reasons that he is not describing. > > -- > David. > > > In R-3.1.3 we got > > rapply(list(quote(1+myNumber)), evalq, envir=list2env(list(myNumber=17))) > > #[1] 18 > > rapply(list(quote(1+myNumber)), eval, envir=list2env(list(myNumber=17))) > > #Error in (function (expr, envir = parent.frame(), enclos = if > > (is.list(envir) || : > > object 'myNumber' not found > > lapply(list(quot...
2015 Jul 15
0
bquote/evalq behavior changed in R-3.2.1
...estion on StackOverflow, but Dayne was >>> not happy with that solution for other reasons that he is not describing. >>> >>> -- >>> David. >>> >>> > In R-3.1.3 we got >>> > rapply(list(quote(1+myNumber)), evalq, >>> envir=list2env(list(myNumber=17))) >>> > #[1] 18 >>> > rapply(list(quote(1+myNumber)), eval, >>> envir=list2env(list(myNumber=17))) >>> > #Error in (function (expr, envir = parent.frame(), enclos = if >>> > (is.list(envir) || : >>> > object ...
2015 Sep 29
3
making object.size() more meaningful on environments?
Hi, Currently object.size() is not very useful on environments as it always returns 56 bytes, no matter how big the environment is: env1 <- new.env() object.size(env1) # 56 bytes env2 <- new.env(hash=TRUE, size=75000000L) object.size(env2) # 56 bytes env3 <- list2env(list(a=runif(25000000), L=LETTERS)) object.size(env3) # 56 bytes This makes it pretty useless on reference class instances and other objects that use environments internally for caching or other purposes. What about changing this and make it return something more meaningful? Cheers, H. --...
2016 Oct 02
5
On implementing zero-overhead code reuse
...mport("foo") ## foo$bar() path <- file.path(Sys.getenv("PROJ_R_LIB"),paste0(name,".R")) if(!file.exists(path)) stop('file "',path,'" does not exist') mod <- new.env() source(path,local=mod) list2env(setNames(list(mod),list(name)),envir=parent.frame()) invisible() } (NB: the idea above is an elaboration of the one I showed in my first post.) But this is very much of an R noob's solution. I figure there may already be more solid ways to achieve "zero-overhead" code r...
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
Thanks Duncan, I know about list2env(), in fact a previous version of collapse::`%=%` was coded as "%=%" <- function(lhs, rhs) { if(!is.character(lhs)) stop("lhs needs to be character") if(!is.list(rhs)) rhs <- as.vector(rhs, "list") if(length(lhs) != length(rhs)) stop("length(lhs) no...
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
I think the standard way to do this in R is given by list2env(), as described in a couple of answers on the SO page you linked. The syntax you proposed would be likely to be confusing in complex expressions, e.g. f(A, C, Q, R = init_matrices(X, Y, Z)) would obviously not work but wouldn't trigger a syntax error, and f((A, C, Q, R = init_matric...
2018 Oct 26
2
Bug report for sealClass() in Core-maintained package "methods"
...alClass() without specifying the 'where' argument. I have found this issue in R 3.2.3 and R 3.4.0. For example: > setClass("foo", slots=c(name="character", age="integer")) > isSealedClass("foo") [1] FALSE > sealClass("foo") Error in list2env(list(<environment>), NULL, <environment>) : names(x) must be a character vector of the same length as x > isSealedClass("foo") [1] FALSE > sealClass("foo", where=.GlobalEnv) > isSealedClass("foo") [1] TRUE I found that this is because sealClass(...
2011 Jan 11
1
as.environment.list provides inconsistent results under torture
...mean = 0, sd = 1) : correspondance partielle de cha?nes de caract?res incorrecte Is it because the call made by lang4 is not protected while evaluated in this line : case VECSXP: { /* implement as.environment.list() {isObject(.) is false for a list} */ return(eval(lang4(install("list2env"), arg, /*envir = */R_NilValue, /* parent = */R_EmptyEnv), rho)); } (BTW, this was detected in a looooooooong Rcpp-devel thread. See http://comments.gmane.org/gmane.comp.lang.r.rcpp/1336) Romain -- Romain Francois Professional R Enthusiast +33(0) 6 28 91 30 30 http://roma...
2023 Mar 11
1
Multiple Assignment built into the R Interpreter?
On 11/03/2023 9:54 a.m., Sebastian Martin Krantz wrote: > Thanks Duncan, > > I know about list2env(), in fact a previous version of collapse::`%=%` > was coded as > > "%=%" <- function(lhs, rhs) { > ?? if(!is.character(lhs)) stop("lhs needs to be character") > ?? if(!is.list(rhs)) rhs <- as.vector(rhs, "list") > ?? if(length(lhs) != leng...
2019 Aug 15
1
Rf_defineVar(symbol, R_UnboundValue, environment) questions
...ineVarAsUnboundValue.o gcc -std=gnu99 -shared -L/home/R/R-3.6.1/lib64/R/lib -L/usr/local/lib64 -o defineVarAsUnboundValue.so defineVarAsUnboundValue.o -L/home/R/R-3.6.1/lib64/R/lib -lR erratic:bill:293% R-3.6.1 --quiet --vanilla > dyn.load("defineVarAsUnboundValue.so") > envir <- list2env(list(One=1, Two=2)) > objects(envir) [1] "One" "Two" > > .Call("defineVarAsUnboundValue", quote(Two), envir) NULL > objects(envir) [1] "One" > objects(envir, all.names=TRUE) # is "Two" a 'hidden' object? [1] "One" &q...
2015 Sep 29
1
making object.size() more meaningful on environments?
...ronments as it always > returns 56 bytes, no matter how big the environment is: > > env1 <- new.env() > object.size(env1) # 56 bytes > > env2 <- new.env(hash=TRUE, size=75000000L) > object.size(env2) # 56 bytes > > env3 <- list2env(list(a=runif(25000000), L=LETTERS)) > object.size(env3) # 56 bytes > > This makes it pretty useless on reference class instances and other > objects that use environments internally for caching or other purposes. > > What about changing this and make it return...
2016 Oct 03
4
On implementing zero-overhead code reuse
...gt;> path <- file.path(Sys.getenv("PROJ_R_LIB"),paste0(name,".R")) >> if(!file.exists(path)) stop('file "',path,'" does not exist') >> mod <- new.env() >> source(path,local=mod) >> list2env(setNames(list(mod),list(name)),envir=parent.frame()) >> invisible() >> } >> >> (NB: the idea above is an elaboration of the one I showed in my first post.) >> >> But this is very much of an R noob's solution. I figure there may >> already b...
2023 Mar 11
3
Multiple Assignment built into the R Interpreter?
...quot;C") %=% init_matrices()) returns numeric(0), with A and C having their values assigned. > suppose f() returns list(A = 1, B = 2) and I do > B, A <- f() > Should assignment be by position or by name? In other languages this is by position. The feature is not meant to replace list2env(), and being able to rename objects in the assignment is a vital feature of codes using multi input and output functions e.g. in Matlab or Julia. > Honestly, given that this is simply syntactic sugar, I don't think I would support it. You can call it that, but it would be used by almost ev...
2015 Sep 29
0
making object.size() more meaningful on environments?
...() is not very useful on environments as it always > returns 56 bytes, no matter how big the environment is: > > env1 <- new.env() > object.size(env1) # 56 bytes > > env2 <- new.env(hash=TRUE, size=75000000L) > object.size(env2) # 56 bytes > > env3 <- list2env(list(a=runif(25000000), L=LETTERS)) > object.size(env3) # 56 bytes > > This makes it pretty useless on reference class instances and other > objects that use environments internally for caching or other purposes. > > What about changing this and make it return something more me...
2016 Oct 02
0
On implementing zero-overhead code reuse
...## foo$bar() > path <- file.path(Sys.getenv("PROJ_R_LIB"),paste0(name,".R")) > if(!file.exists(path)) stop('file "',path,'" does not exist') > mod <- new.env() > source(path,local=mod) > list2env(setNames(list(mod),list(name)),envir=parent.frame()) > invisible() > } > > (NB: the idea above is an elaboration of the one I showed in my first post.) > > But this is very much of an R noob's solution. I figure there may > already be more solid ways to achie...