coming back to this post years later to add yet another warning: DONT DO THIS
I am trying to store a variable from a function in the global environment, but none of the solutions I found SO post or different SO post worked for me. This is an extremely simplified example to illustrate my problem. I cannot just use the <<- to make v global because my actual function creates several dozen variables.
Code (main_file.R)
source("function_me.R") #environment(doGlobalThing) <-parent.frame(2) #didnt work doGlobalThing() v #cant get to this var from the global environment Code (function_me.R)
doGlobalThing<-function(){ #eval(v<-'hi',env=parent.frame(2)) #tried this, didnt work v<-'hi' }