| interactive {base} | R Documentation |
Is R Running Interactively?
Description
ReturnTRUE whenR is being used interactively andFALSE otherwise.
Usage
interactive()Details
An interactiveR session is one in which it is assumed that there isa human operator to interact with, so for exampleR can prompt forcorrections to incorrect input or ask what to do next or if it is OKto move to the next plot.
GUI consoles will arrange to startR in an interactive session. WhenR is run in a terminal (viaRterm.exe on Windows), itassumes that it is interactive if ‘stdin’ is connected to a(pseudo-)terminal and not if ‘stdin’ is redirected to a file orpipe. Command-line options--interactive (Unix) and--ess (Windows,Rterm.exe) override the defaultassumption.(On a Unix-alike, whether thereadline command-line editor isused isnot overridden by--interactive.)
Embedded uses ofR can set a session to be interactive or not.
Internally, whether a session is interactive determines
how some errors are handled and reported, e.g. see
stopandoptions("showWarnCalls").whether one of--save,--no-save or--vanilla is required, and ifR ever asks whether to save theworkspace.
the choice of default graphics device launched when needed andby
dev.new: seeoptions("device")whether graphics devices ever ask for confirmation of a newpage.
In addition,R's ownR code makes use ofinteractive(): forexamplehelp,debugger andinstall.packages do.
Note
This is aprimitive function.
See Also
Examples
.First <- function() if(interactive()) x11()