similar to: What is the most efficient way to assign to PARTS of objects in other frames/environments?

Displaying 20 results from an estimated 10000 matches similar to: "What is the most efficient way to assign to PARTS of objects in other frames/environments?"

2002 May 17
0
What is the most efficient way to assign to PARTS of obje cts in other frames/environments?
For nested function calls it appears that a combination of environment() and '<<-' will also work: f1 <- function() { x <- rep(NA,4) # Object to be modified by function f2 environment(f2) <- sys.frame(1) # Make f1's environment available to f2 f2(2) # Changes 2nd element of x print(x) } f2 <- function(i) { #
2011 Mar 10
2
Create an environment and assign objects to it in one go?
Hi, I've just created: newEnvEval <- function(..., hash=FALSE, parent=parent.frame(), size=29L) { envir <- new.env(hash=hash, parent=parent, size=size); evalq(..., envir=envir); envir; } # newEnvEval() so that I can create an environment and assign objects to it in one go, e.g. env <- newEnvEval({ a <- 1; b <- 2; }); print(env$a); Does this already exists somewhere?
2014 Oct 17
2
Most efficient way to check the length of a variable mentioned in a formula.
Dear R gurus, I need to know the length of a variable (let's call that X) that is mentioned in a formula. So obviously I look for the environment from which the formula is called and then I have two options: - using eval(parse(text='length(X)'), envir=environment(formula) ) - using length(get('X'), envir=environment(formula) ) a bit of
2001 Apr 04
0
factors and characters when attaching data...
Can someone help me with the following problem... I have a dataframe with 62 columns a number of these are as.character and a number of these are as.double, I read these into R-1.2.0 as... > Version3.Studies_read.table("c:\\Version3.Studies.dat",sep="\t", as.is=TRUE, header=TRUE,strip.white=TRUE) This is fine up to here, I've checked to see if the data has been
2002 Aug 06
1
polygon() draws non-transparent border, erase.screen draws non-transparent border (PR#1881)
# polygon ignores requests to have its border transparent, look at par(bg="transparent") plot(c(0, 3), 0:1) polygon(c(0, 1, 1, 0), c(0, 0, 1, 1), border=NA, col = 0) polygon(c(1, 2, 2, 1), c(0, 0, 1, 1), border="transparent", col = 0) polygon(c(2, 3, 3, 2), c(0, 0, 1, 1), border=0, col = 0) # a quick fix for erase.screen() is the following erase.screen <- function (n =
2016 Apr 20
1
locked environments
Shouldn't the following 4 ways to alter an object in a locked environment either all work or all fail? (All working would be nice, I think.) E <- new.env() assign("var", c(1,2,3,4), envir=E) lockEnvironment(E, bindings=FALSE) E$var[1] <- 101 ; E$var #[1] 101 2 3 local(var[2] <- 102, envir=E) #Error in eval(expr, envir, enclos) : # cannot add
2020 Jul 13
0
CentOS 8 & HandBrakeCLI
On 7/13/20 4:04 AM, Frank M. Ramaekers Jr. wrote: > Since I upgraded to CentOS8, I cannot get HandBrakeCLI to work: > > # HandBrakeCLI > HandBrakeCLI: error while loading shared libraries: libass.so.5: cannot open shared object file: No such file or directory > > Googling this, it appears the error message is related to ffmpeg, but I don't get any error message with it:
2020 Jul 13
3
CentOS 8 & HandBrakeCLI
Since I upgraded to CentOS8, I cannot get HandBrakeCLI to work: # HandBrakeCLI HandBrakeCLI: error while loading shared libraries: libass.so.5: cannot open shared object file: No such file or directory Googling this, it appears the error message is related to ffmpeg, but I don't get any error message with it: # ffmpeg ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers ?
2009 Feb 15
2
Passing environments: why doesn't this work???
This is a trivial example I set up to see if I could pass an environment and use the variables in it (this is for a function that will be called many times and might need to use a lot of variables that won't be changing, so it seemed more sensible to use an environment). Here's the code: ######################### #The outer function run.internal.env <- function(x) { in.env <-
2010 Jan 25
1
ff package: ff objects don't reload completely on NFS drives from a different machine
Try to close the file on the first nfs client before reopening it on the second nfs client. NFS has something called "close-to-open cache consistency". This means that two clients which have the same nfs file open, cannot rely on seeing the updates from the respective other client. If one clients closes, and the other client opens thereafter, it should see the changes. If you want
2015 Apr 29
2
Formula evaluation, environments and attached packages
Hi! Some time ago, I replaced calls to library() with calls to requireNamespace() in my package logmult, in order to follow the new CRAN policies. But I just noticed it broke jackknife/bootstrap using several workers via package parallel. The reason is that I'm running model replicates on the workers, and the formula includes non-standard terms like Mult() which are provided by gnm. If gnm
2000 Feb 11
1
Something strange in "?assign"? (PR#433)
According to the assign helpfile (0.90.1) the "assign" function is function (x, value, pos = -1, envir = sys.frame(sys.parent()), inherits = FALSE, immediate = TRUE) which is not quite the implementation, which is function (x, value, pos = -1, envir = pos.to.env(pos), inherits = FALSE, immediate = TRUE) This seems to have the following interesting effect. "short.fun"
2002 May 07
2
names(unlist(...)) may construct corrupt strings (PR#1524)
names(unlist(...)) seems to be able to construct corrupt strings detected via: two identical strings behave different in paste observed in RW1.4.1 and RW1.5.0 pure replication code after output Best Jens Oehlschlägel > l <- names(unlist(list(aa = list(bb = 1)))) > l [1] "aa.bb" > # this is exactly "aa.bb" > identical(l, "aa.bb") [1] TRUE > >
2010 Mar 15
2
Strange behavior of assign in a S4 method.
Hi the list, I define a method that want to change an object without assignation (foo(x) and not x<-foo(x)) using deparse and assign. But when the argument of the method does not match *exactly* with the definition of the generic function, assign does not work... Anything wrong? Christophe #------ Does not work ------#
2010 Jul 21
1
Objects within environment
Hi all, I have following environments loaded with my current R session: > search() [1] ".GlobalEnv" "package:stats" "package:graphics" "package:grDevices" [5] "package:utils" "package:datasets" "package:methods" "Autoloads" [9] "package:base" How can I find the objects
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
2008 Mar 07
3
merging environments
Despite the spirited arguments of various R-core folks who feel that mle() doesn't need a "data" argument, and that users would be better off learning to deal with function closures, I am *still* trying to make such things work in a reasonably smooth fashion ... Is there a standard idiom for "merging" environments? i.e., suppose a function has an environment that I want
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
2012 Feb 04
1
'deparse(substitute'))' then 'assign' in a S4 methods
Hi the list, I am writing a function in which I need to affect a variable on a higher level. My fnction could be: ++++++++++++++++++ fooBis <- function(x){ nameObject <- deparse(substitute(x)) print(nameObject) assign(nameObject,4,envir=parent.frame()) } > fooBis(e) [1] "e" > e [1] 4 ----------------- (to simplify, this fnction can affect only the number
2001 May 30
2
environments
I would like to be able, inside a function, to create a new function, and use it as part of a formula as an argument to, say, gnls or nlme. for example: MyTop <- function(data=dta) { Cexp <- function(dose,A,B,m){...} Model <- as.formula(paste("y","~ Cexp(",paste(formals(Cexp),collapse =", "),")")) MyCall <-