Error in Rscript
1
0
Entering edit mode
7.2 years ago
abedkurdi10 ▴ 190

Hello all, I wrote an R script, when I run it inside R (using source('/path/to/file.R') it works well. When I run it using Rscript from command line, it throws the following error:

Error in ha_pct + ht : non-numeric argument to binary operator
Calls: oncoPrint
Execution halted

Does anyone knows what's causing the problem and how to solve it?

Thank you.

R error Rscript • 1.5k views
ADD COMMENT
3
Entering edit mode
7.2 years ago

If you are reading in options from the command line via Rscript, then the variables will be stored as characters (i.e., strings).

If your downstream operation requires numerical arguments (which is what your error seems to indicate), then after you read in options in Rscript, use as.numeric() to coerce the type of the specified variable from character to numeric.

Generally, see ?as.numeric() and ?is.numeric() to read about how to coerce and test your variables, if you think one of them is not a number.

ADD COMMENT

Login before adding your answer.

Traffic: 2646 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6