Here is my code:
Args <- commandArgs();
for(i in 1:length(Args)){
if(Args[i] == "--input") input = Args[i+1]
if(Args[i] == "--output") fig = Args[i+1]
if (Args[i] == "--height") fig_height = as.numeric(Args[i+1])
if (Args[i] == "--width") fig_width = as.numeric(Args[i+1])
}
cat(input, fig, fig_height, fig_width, "\n")
I put it in a text file. If I run this code on the terminal:
R --vanilla --slave --input xx --height 10 --width 14 --output out < test.R
I'll get the warning message shown as below:
WARNING: unknown option '--input'
ARGUMENT 'xx' ignored
WARNING: unknown option '--height'
ARGUMENT '10' ignored
WARNING: unknown option '--width'
ARGUMENT '14' ignored
WARNING: unknown option '--output'
ARGUMENT 'out' ignored
xx out 10 14
How can I get rid of the `WARNING` and 'ARGUMENT 'xx' __ignored__'?
Thanks.
I found a way to avoid warning message: Instead of using:
R --vanilla --slave --input xx --height 10 --width 14 --output out < test.R
I use:
Rscript test.R --input xx --height 10 --width 14 --output out
Then there is no warning message and here is the output:
xx out 10 14
Hope this can help others.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments