Limiting variable scope

后端 未结 4 2114
北荒
北荒 2020-11-30 12:50

I\'m trying to write a function, which limits the scope of R variables. For example,

source(\"LimitScope.R\")
y = 0
f = function(){
   #Raises an error as y          


        
4条回答
  •  孤城傲影
    2020-11-30 13:17

    You can check if y exists in the global environment using exists('y',envir=.GlobalEnv)

提交回复
热议问题