8
votes

I am running some R code that has a recursion depth of 5000 and I get the following error:

Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
Error during wrapup: evaluation nested too deeply: infinite recursion / options(expressions=)?

How do I set the recursion depth in R?

2

2 Answers

14
votes

Ah. Found it by reading the error message. This will set the recursion depth to 100000

> options(expressions= 100000)
-1
votes

I tried this. You can set it, and using "options()" again, shows it set:

options(expressions=255) options() .... $expressions [1] 255 ....

But unfortunately, it doesn't work. The recursion fails in exactly the same way. I've tried stripping the many extra columns off my data, and it doesn't help.

I originally solved this problem with a for() loop, but it's about 70k rows of data, and as any experienced R programmer knows, you're doomed to very long runs once you put a for() loop in with a big data set.

This is R version 3.4.1, running on 64-bit Windows.