1

I'd like the flow of control to vary depending on where an R program is called from. Something like

if (called_from == 'GUI') {
print('Hello GUI')} else {
print('Hello command line')
}

Is this possible? If so, please provide as many details as possible.

Argent
  • 885
  • 2
  • 9
  • 18
  • You can use `interactive()`. If TRUE the code is probably being run in a GUI, if FALSE, it's probably being run at the command line. See the `?interactive` help page for more details. – MrFlick Jun 26 '19 at 14:57

1 Answers1

3
if (interactive()) {
  print('Hello GUI')
} else {
  print('Hello command line')
}
the-mad-statter
  • 5,650
  • 1
  • 10
  • 20