I am having trouble while debugging my code. The code is shown below. So, within my lapply function there is something going wrong. To determine the bug I am writing the three params into a global variable. But what happing is the following: The list length (within the first print) is always 3 (as it should be), also in the second print, foo has length 3. Perfect. After these lines, the bug occurs, execution breaks and when I then take a look at my variable foo, it has length 4 and only the vl variable occurs within foo. I have no other allocation of foo somewhere else in my code, also this is the only global variable I am using.
What am I missing? I can't explain myself this behaviour.
With best regards,
Mario
.evalModel = function(model, vl, params){
print(length(list(model, vl, params)))
foo<<-list(model, vl, params)
print(length(foo))
modelPerformance = lapply(model, function(x){
ruleResults = vector(mode="list", length = length(x) )
for(i in 1:length(x)){
if(class(x[[i]]) == "rule"){
ruleResults[[i]] = .evalRule(x[[i]] , vl, params)
} else{
ruleResults[[i]] = .evalRule(x[[i]]$rule , vl, params)
}
}
ruleResults
})
class(modelPerformance) = "GP-Model"
return(modelPerformance)
}