How to suppress the warming message by R when using commandArgs()

xie186

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.

xie186

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to suppress R startup message?

From Dev

How to suppress the error message when dividing 0 by 0 using np.divide (alongside other floats)?

From Dev

Suppress error message in R

From Dev

Suppress error message in R

From Dev

How to suppress awk output when using FS?

From Dev

How to suppress download.file() "trying URL..." message in R?

From Dev

How to suppress warning message in R regarding closing unused connection?

From Dev

How do I suppress row names when using DT::renderDataTable in R shiny?

From Dev

Suppress bold when using "__"

From Dev

How to suppress error message of a command?

From Dev

How to suppress OpenCV error message

From Dev

How can I suppress command output when using backticks?

From Dev

How to suppress infinite loop note when using "IF 0 THEN SET"

From Dev

Suppress tempdb message when outputting result set

From Dev

Suppress convergence message in nnet multinom function in R

From Dev

Not able to suppress the error message using /dev/null

From Dev

How to suppress Debian uname message when ssh'ing into the machine? Plus changing it to something else, if possible

From Dev

Outlook web Addin: how to suppress the default notification message comes up when clicking on the button

From Dev

How to suppress [no test files] message on go test

From Dev

PostgreSQL - How to suppress query statement message

From Dev

How to suppress certain error message in 'find' command?

From Dev

How to suppress File in use alert message

From Dev

How to suppress text using JQuery?

From Dev

Suppress 'file truncated' messages when using tail

From Dev

R testthat package: How can I see output from message() when using test_file()

From Dev

Unable to suppress clipboard warning message when closing a file

From Dev

Suppress Message Box R6025 Pure Virtual Function Call

From Dev

How to suppress warnings in maven output when using maven-checkstyle-plugin?

From Dev

How to suppress zeroes when using geom_histogram with scale_y_log10

Related Related

  1. 1

    How to suppress R startup message?

  2. 2

    How to suppress the error message when dividing 0 by 0 using np.divide (alongside other floats)?

  3. 3

    Suppress error message in R

  4. 4

    Suppress error message in R

  5. 5

    How to suppress awk output when using FS?

  6. 6

    How to suppress download.file() "trying URL..." message in R?

  7. 7

    How to suppress warning message in R regarding closing unused connection?

  8. 8

    How do I suppress row names when using DT::renderDataTable in R shiny?

  9. 9

    Suppress bold when using "__"

  10. 10

    How to suppress error message of a command?

  11. 11

    How to suppress OpenCV error message

  12. 12

    How can I suppress command output when using backticks?

  13. 13

    How to suppress infinite loop note when using "IF 0 THEN SET"

  14. 14

    Suppress tempdb message when outputting result set

  15. 15

    Suppress convergence message in nnet multinom function in R

  16. 16

    Not able to suppress the error message using /dev/null

  17. 17

    How to suppress Debian uname message when ssh'ing into the machine? Plus changing it to something else, if possible

  18. 18

    Outlook web Addin: how to suppress the default notification message comes up when clicking on the button

  19. 19

    How to suppress [no test files] message on go test

  20. 20

    PostgreSQL - How to suppress query statement message

  21. 21

    How to suppress certain error message in 'find' command?

  22. 22

    How to suppress File in use alert message

  23. 23

    How to suppress text using JQuery?

  24. 24

    Suppress 'file truncated' messages when using tail

  25. 25

    R testthat package: How can I see output from message() when using test_file()

  26. 26

    Unable to suppress clipboard warning message when closing a file

  27. 27

    Suppress Message Box R6025 Pure Virtual Function Call

  28. 28

    How to suppress warnings in maven output when using maven-checkstyle-plugin?

  29. 29

    How to suppress zeroes when using geom_histogram with scale_y_log10

HotTag

Archive