I have the following error showing up in Rstudio when I run the code below:
Error: evaluation nested too deeply: infinite recursion / options(expressions=)?
I have tested it on 3 computers (2 OSX and 1 Windows) with recent (different but all 2023) versions of RStudio and R and more than 32GB memory each with the same result. Furthermore, if I try to open a project created a year ago with formulas with many variables, I get the same error when I try to load the .Rdata file, when it used to work perfectly.
On the other hand, the same line of code works with no issue if I run it in a R console.
I have tried to set a larger value than the default one in options(expressions=) as suggested in a few posts talking about this error, and this yields to a different error: Error: C stack usage 7954392 is too close to the limit
Since I have updated RStudio on all computers where the command used to work, I am suspecting there have been a breaking change in one of the updates, but I have no clue what happened nor what I can do to solve the issue. Any suggestion would be welcome.
I need to transform the string into a formula to use it in various functions (Hmisc::redun, gbm::gbm among others). If I leave it as a string, the error occurs when using the function that tries to convert it.
Also note that you can make it work with a smaller number of variables (e.g. 1000 works). The real use case consists of reading colnames from a data frame and in this case, the error occurs after adding more than 600 variables with longer names. Not sure why it makes a difference but it does.
You were actually helpful: I have tried to pass formula(string) after defining the string as you suggested within the redun() function and it is running without error for now. It might just be a matter of time as the task might take a while to complete. I will report the outcome when the analysis is complete.