search for: conditional1

Displaying 1 result from an estimated 1 matches for "conditional1".

Did you mean: conditional
2012 Feb 13
3
If (x > 0)
...run. Take one number from the command line. If the number < 0 return -1. If number > 0 return 1 and if the number == 0 return 0. The code is in a file called test1.R The code: #useage: R --no-save --args 5 < test1.R args = (commandArgs(TRUE)) x = as.numeric(args[1]) print(x) res <- conditional1(x) cat("result= ",res,"\n") conditional1 <- function(x){ result <- 0 if (x > 0) { result <- 1 } else if (x < 0) { result <- -1 } return(result) } The output: >R --no-save --slave --ar...