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?
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.