且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

R脚本:确定脚本是在GUI中运行还是从命令行运行

更新时间:2023-12-04 22:37:46

也许你正在寻找 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()?