How to solve 'protection stack overflow' issue in R Studio

旧城冷巷雨未停 提交于 2019-11-29 03:58:37

@Ansjovis86

You can specify the ppsize as a command line argument to Rstudio

rstudio.exe --max-ppsize=5000000

You may also with to set the expression option via your .Rprofile or at runtime by using the options(expressions = 5e5) command.

> options(expressions = 5e5)
>?options

...

expressions:

sets a limit on the number of nested expressions that will be evaluated. Valid values are 25...500000 with default 5000. If you increase it, you may also want to start R with a larger protection stack; see --max-ppsize in Memory. Note too that you may cause a segfault from overflow of the C stack, and on OSes where it is possible you may want to increase that. Once the limit is reached an error is thrown. The current number under evaluation can be found by calling Cstack_info.

Cstack_info() - to determine current setting.s

The root cause is the model.matrix function, which will 1) use a lot of memory; and 2) throw this error for a sufficiently large no. of columns.

Try using my glmnetUtils package, which will get around both these problems. Rather than building the model matrix in one go, it does it term by term; and it also doesn't try to evaluate huge formulas. This is a lot faster, and doesn't risk blowing up the stack.

install.packages("glmnetUtils")
library(glmnetUtils)
glmnet(response ~ ., data = acgh_frame[3:ncol(acgh_frame)])
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!