R脚本:确定脚本是在GUI中运行还是从命令行运行 [英] R Script: Determine whether the script is run in the GUI or from command line
本文介绍了R脚本:确定脚本是在GUI中运行还是从命令行运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以从脚本中确定脚本是否在R-GUI(特别是OS X上的R.app)上运行,或者是否已从终端/命令行调用(即 R --vanilla -f script.R
)?
doMC
library),不应该从GUI中使用。有时我需要进一步处理在脚本中计算的数据,所以我想在这些情况下从GUI调用脚本。解决方案
也许你正在寻找 interactive()
?
Is it possible to determine - from within the script - whether the script is running in the R-GUI (specifically R.app on OS X) or whether it has been called from Terminal/command line (i.e. R --vanilla -f script.R
)? If so, how is this possible?
I'm asking because I have a script that can run parallelized (using the doMC
library), which should not be used from the GUI. Sometimes I need to further process the data calculated in the script, so I'd like to call the script from the GUI on these occasions.
解决方案
Perhaps you are looking for interactive()
?
这篇关于R脚本:确定脚本是在GUI中运行还是从命令行运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文