我有一个名为class_df的数据帧,它是2683 obs . 18050变量 . 我不确定这部分是否重要,但在调用object.size(class_df)时,我得到的是389586976字节(~390 MB) .

尝试运行以下代码时出错:

#Run randomForest on 80% of the dataset
smp_size <- floor(0.80 * nrow(class_df)) 
train_ind <- sample(seq_len(nrow(class_df)), size = smp_size)
train <- class_df[train_ind, ] 
test <- class_df[-train_ind, ]
#Fit the model to classify "Level"
model <- randomForest(Level~., data = train)

我得到的错误是:

> Error: protect(): protection stack overflow

我试图使用运行的命令行设置--max-ppsize:

C:\Program Files\RStudio\bin>rstudio.exe --max-ppsize = 5000000

这打开了RStudio窗口,我从那个窗口打开了文件,并得到了同样的错误 .

基于对相关问题的回答,我还在我的程序中添加了以下内容,但无济于事:

options(expressions = 5e5)

最后,当我调用Cstack_info()时,根据选项文档,我得到以下内容:

size    current  direction eval_depth 
  19922944      16232          1          2

最后一块拼图令我困惑 . “当前”表示“16232”的事实是否意味着当我调用命令行函数时max-ppsize没有增加?或者我误解了Cstack_info()的输出?

我该怎么从这里开始呢?

编辑:我有点设法通过使用h2o包来解决这个问题,但我仍然希望找到一个解决方案,而无需使用它 .