2

I have written a series of functions to allow easier 'arg-parse'-type commandline argument parsing and check in R. I have run into the issue briefly mentioned here but still don't entirely understand whats going on. It seems that when trying to use "-g" as a flag,

$ Rscript test_args.R -g foo

where test_args.R is simply:

#minimal program for reproducing "-g" arg behaviour
args<-commandArgs(T)
print(args)

I get the error and output:

WARNING: unknown gui 'foo', using X11

[ 1 ] "-g" "foo"

it interprets that as something to change the GUI prior to actually running the script test_args.R (although the printed message shows that the "-g" does actually make it to the actual R program). This isn't mentioned in the Rscript man page, or anywhere else I can find.

Is there any way around this, and if not, is there a list of any other potential off-limits argument flags?

Thanks in advance!

EDIT: based of of this post, I tried adding either the hash-bang #!/usr/bin/Rscript, but would ideally like to avoid users having to install littler to use the #!/usr/local/bin/r option if possible...

Community
  • 1
  • 1
NWaters
  • 1,163
  • 1
  • 15
  • 27
  • The Rscript is basically passing things off to R. Any options that you can pass to R you can also pass to Rscript. One parameter that R accepts is `-g` to change the GUI type. (See the `R --help` page for more information). You should probably avoid using `-g` as an option for your script. (tested with R version 3.2.4 x86_64-pc-linux-gnu (64-bit)) – MrFlick Apr 21 '16 at 15:21
  • That does not happen to me under Windows. Note that the message is a warning and not an error. – G. Grothendieck Apr 21 '16 at 15:22
  • @MrFlick ok, I see that on the R help page. However, the other R flags cause any effect (I've tried '-h', '--args', '-e'). Is this something unique to the '-g' case? – NWaters Apr 21 '16 at 17:14
  • @G.Grothendieck noted, thank you! – NWaters Apr 21 '16 at 17:15
  • Check out the answer by @klrmlr :) http://stackoverflow.com/questions/30698581/how-to-prevent-command-line-args-from-being-interpreted-by-r-vs-only-by-my-scri – chinsoon12 Apr 21 '16 at 22:18

0 Answers0