我有一个功能:
myfunctionIs=myfunct(x,y){
#Some calculations and assign my lists to globalenv
theList1<<-theList1
theList2<<-theList2
#Nested function
function(...){
theList1=get("theList1")
theList2=get("theList2")
##Some calculations...
#NamesList calculation
NamesList= ###Some Calculations
ListContainer=c(deparse(substitute(theList1)),deparse(substitute(theList2)))
for (i in seq_along(ListContainer)){
assign(ListContainer[i],mapply(function(x,y) {
##Some calculations
return(x)
},x=get(ListContainer[i],envir=parent.env(environment())),y=NamesList,SIMPLIFY = FALSE),
envir=.GlobalEnv)
}
}}
我正在尝试将List1和theList2分配回.GlobalEnv,但是我收到了错误
Error in get(ListContainer[i], envir = parent.env(environment())) :
object 'structure(list("2002-12-31" = structure(list(Date = c("2000-01-31", ' not found
我认为错误来自
get(ListContainer[i],envir=parent.env(environment()))
因为calculations work correctly if I work in GlobalEnvironment
。
有什么想法吗? 最诚挚的问候
EDIT
这样可行:
将ListContainer
更改为:
ListContainer=c("theList1","theList2")
函数内部有deparse(substitute...
的问题。
答案 0 :(得分:0)
可行:将ListContainer更改为:
ListContainer=c("theList1","theList2")
deparse(substitute(..))
部分存在问题。
或许也可以通过一些调整来实现:
ListContainer=c(quote(theList1),quote(theList2))
然后
eval(ListContainer[i])
在循环中。