R 没有响应中断停止进程的请求

R not responding request to interrupt stop process

时不时地,我不得不 运行 一个需要花费大量时间的函数,我需要在它完成之前中断处理。为此,我单击 Rstudio 控制台顶部的红色“停止”标志,这通常是 returns 下面的消息:

R is not responding to your request to interrupt processing so to stop the current operation you may need to terminate R entirely.

Terminating R will cause your R session to immediately abort. Active computations will be interrupted and unsaved source file changes and workspace objects will be discarded.

Do you want to terminate R now?

问题是我点击“否”,然后 Rstudios 似乎完全冻结。我想知道其他人是否面临类似的问题,是否有任何方法可以解决这个问题。

有没有办法在不丢失工作区中的对象的情况下快速停止 Rstudio 中的进程?

不幸的是,RStudio 目前无法在几种情况下中断 R:

  1. R正在执行一个外部程序(例如你不能中断system("sleep 10")),

  2. R 正在执行(例如)C/C++ 库调用,该调用不为 R 提供检查中断的机会。

在这种情况下,唯一的选择是强行终止 R 进程——希望这会在 RStudio 的未来迭代中改变。


编辑:RStudio v1.2 现在应该可以更好地处理许多此类上下文中的中断。

当 R 不在 R 中工作并且正在调用外部库调用时,可能会发生这种情况。唯一的选择是关闭项目 window。幸运的是,包括对象在内的未保存更改在再次打开 RStudio 时会保留下来。