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

十年热恋 提交于 2019-11-27 13:55:45

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!