user interface - R Is Run in GUI or Not? -
i note following, click here:
i ask same question, in sense need know whether r environment has been run terminal, or in gui type environment.
the motivation question, produce number of .pdf
reports, and, if user has called functions produce reports under gui, want open reports using system default .pdf
program, if script has been run command line, or via session commenced @ commandline, should suppressed.
in rstudio, if run interactive()
, result true
, , if open r session @ terminal , run same command, result true
, so, question essentially, how can differentiate? running macosx, answer relevant mac, unix , windoze.
cheers,
commandargs()
output command line launched r session , .platform$os.type
report os so:
switch(.platform$os.type, windows = if (grepl("rterm", commandargs())) cat("terminal\n") else cat("gui\n"), ...fill in each other operating system... )
Comments
Post a Comment