单击 "Run the current line or selection" 时停止执行
stop execution when you click "Run the current line or selection"
在 RStudio 中,如果您执行 selection,是否有办法停止脚本的执行?
我的问题是大多数 "my users" 喜欢 select 整个脚本并单击 "Run the current line or selection (Ctrl+Enter)" 而不是获取脚本。
我的脚本中有一些 stop
命令,用于停止执行并警告用户哪里出了问题。但是 select 处理所有内容和 运行,脚本将继续。有没有办法解决这个问题,强制停止正在进行的执行?
只是一个最小的例子:
if(TRUE) stop('stop here')
print('continue')
我想解释人们不执行 selection 而执行采购更容易,但无论如何这在我的工作组中经常发生。
您可以为所有项目添加 {}
,例如:
{if(TRUE) stop('stop here')
print('continue')
}
比 Ctrl+A Ctrl+Enter
给你
> {if(TRUE)
+ stop('stop here')
+
+ print('continue')
+ }
Error: stop here
在 RStudio 中,如果您执行 selection,是否有办法停止脚本的执行?
我的问题是大多数 "my users" 喜欢 select 整个脚本并单击 "Run the current line or selection (Ctrl+Enter)" 而不是获取脚本。
我的脚本中有一些 stop
命令,用于停止执行并警告用户哪里出了问题。但是 select 处理所有内容和 运行,脚本将继续。有没有办法解决这个问题,强制停止正在进行的执行?
只是一个最小的例子:
if(TRUE) stop('stop here')
print('continue')
我想解释人们不执行 selection 而执行采购更容易,但无论如何这在我的工作组中经常发生。
您可以为所有项目添加 {}
,例如:
{if(TRUE) stop('stop here')
print('continue')
}
比 Ctrl+A Ctrl+Enter
给你
> {if(TRUE)
+ stop('stop here')
+
+ print('continue')
+ }
Error: stop here