Domanda

I designed a function in R that reads a matrix from [x,y] to [0,0] and it studied each value recursively.

For a small matrix I get good output, but for bigger ones (around 1000), R prints a message showing that I might have an infinite recursion problem, but it's not. I tracebacked and the code stopped around 100 iterations before finishing.

Is there a way to increment the number of allowed iterations before considering the function and infinite recursive one? Thanks in advance.

È stato utile?

Soluzione

You can change the maximum recursive depth (e.g. to 10000), with:

options(expressions = 10000)

You can check the current value with:

getOption("expressions")

That being said, if you're iterating over all the elements in a 1000x1000 matrix, you might have a recursive call that is 1000000 deep, and you should probably restructure your code.

I guess it's somewhat amusing this question is being asked on StackOverflow?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top