2
我想問一下,是否有一種功能將我們帶入環境。 例如:搬入環境
# create two environments
Env1 <- new.env()
Env2 <- new.env()
# assign one variable into each environment
assign("v1", "1", envir = Env1)
assign("v2", "2", envir = Env2)
# In order to refer to the variable in Env2 I have to use Env2$v2, for example
print(Env2$v2)
# The question is if there is some function that sents us into Env2
# so that when we refer to the variable in Env2 to use just v2, that is
print(v2)
謝謝大家
你是對的。非常感謝你 –
如果我們嘗試修改它? –
你可以像上面那樣用'assign'修改它。如果使用'<-'進行賦值,則將在當前環境中(位置1)創建一個具有相同名稱的新變量。 –