search for: desired_var

Displaying 2 results from an estimated 2 matches for "desired_var".

2017 Dec 02
2
source files in temp environment
...f rm()'s, but that's a pain, and is messy. I'm wondering if one solution might be to source the code in a temporary environment, assign outputs of interest to the .GlobalEnv with <<-, and then delete the environment afterwards. One way to do this: file.r: temp1 = 1 temp2 = 2 desired_var <<- temp1 + temp2 console: temp_e = new.env() source("file.r", local = temp_e) rm(temp_e) It's a bit messy to create and delete environments, so I tried what others have referred to: source("file.r", local = attach(NULL)) This, however, results in a persistent &qu...
2017 Dec 02
0
source files in temp environment
...s messy. > > I'm wondering if one solution might be to source the code in a temporary > environment, assign outputs of interest to the .GlobalEnv with <<-, and > then delete the environment afterwards. One way to do this: > > file.r: > temp1 = 1 > temp2 = 2 > desired_var <<- temp1 + temp2 > > console: > temp_e = new.env() > source("file.r", local = temp_e) > rm(temp_e) > > It's a bit messy to create and delete environments, so I tried what > others have referred to: > > source("file.r", local = attach(N...