I would like to have a condition in my code which allows me to distinguish if the code is running in Batch or interactive mode (via console). It would be something like this:
if (interactive mode) {do this} else if (Batch mode) {do that}
Is there a way to achieve this? Thanks for your help.
You can use the interactive
function. For example, executing this from a terminal
Rscript -e 'cat(interactive())'
returned FALSE
for me, while executing interactive()
from my RStudio session returned TRUE
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.