Question: Error in Rscript
0
gravatar for abedkurdi10
2.8 years ago by
abedkurdi1020
abedkurdi1020 wrote:

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.

error R rscript • 813 views
ADD COMMENTlink modified 2.8 years ago by Alex Reynolds29k • written 2.8 years ago by abedkurdi1020
3
gravatar for Alex Reynolds
2.8 years ago by
Alex Reynolds29k
Seattle, WA USA
Alex Reynolds29k wrote:

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 COMMENTlink modified 2.8 years ago • written 2.8 years ago by Alex Reynolds29k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 2089 users visited in the last hour