R: copy/move one environment to another

前端 未结 7 1997
-上瘾入骨i
-上瘾入骨i 2020-12-14 02:01

I would like to ask if it is possible to copy/move all the objects of one environment to another, at once. For example:

f1 <- function() {
    print(v1)
          


        
相关标签:
7条回答
  • 2020-12-14 03:02

    Try this:

    f2 <- function() {
        v1 <- 1
        v2 <- 2
        environment(f1) <<- environment()
    }
    
    0 讨论(0)
提交回复
热议问题