Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explanation of R: options(expressions=) to non-computer scientists

Cutting some corners here... The expressions -option sets the maximum number of nested expressions that will be evaluated. With deep recursion the default is sometimes exceeded, and increasing the value often solves the problem. But if it doesn't (a new error message is given), you might need to additionally increase the size of the protection stack. Computers store information about the active routines in stacks. Sometimes when the information doesn't quite fit to the stack, the information is written beyond the stacks boundary, which is bad, since it typically creates, e.g., memory access problems. This can potentially be rectified by by setting the option --max-ppsize when starting R. It's like giving a child a larger paper when he or she overdraws the current paper, and colors the table too.

For more background, see Wikipedia, and links thereof. For details of R's command line options, see An Introduction to R, section B.1.


I guess a site like this is not the right place for a general crash-course on computer science, but in your case there is a match between the site name and the question: You are experiencing a stack overflow! :-)

In computer science, a stack is a data structure where you can access only its last element (a half-queue, so to say). For more information see e.g. Wikipedia or CMU. Stacks play a central role when calling functions, because the return address and often function arguments are stored there. Returning from a function simply means retrieving the return address from the stack and continuing the program execution from the point in code specified by that address.

Since you are applying recursion in your code (calling a function from within itself), the stack grows with every new call. Eventually, your program runs out of memory for storing the whole stack.

See also Memory in R documentation.