Manassa Mauler Manassa Mauler - 8 months ago 48
R Question

Why does the object I usee to store data from a loop throw an error?

nruns <- 100
NLCommand("set N-turtles 100")
for(i in 1:nruns) {
NLDoCommandWhile("count turtles > 99", "go", max.minutes=0)

This code throws an error at the timetaken section saying:

Error in timetaken[[i]] <- NLReport("ticks") :
object 'timetaken' not found

Why is this the case?

Answer Source

The line suggested in the comments works as an answer to my question.

timetaken <- numeric(nruns)