Rscript test0721.R 10,11,12 4 3
test0721.R 如下:
args <- commandArgs(trailingOnly = TRUE)
########a <- as.numeric(args[1])
a <- as.numeric(strsplit(args[1], ",")[[1]])
b <- as.numeric(args[2])
c <- as.numeric(args[3])
myfunc <- function(a,b,c){
result <- (a^b) / c
return(result)
}
final <- myfunc(a,b,c)
print(final)
#write.table(final, file = "teste.txt")
参考:parameter passing - How to pass MULTIPLE values for an argument in R using bash - Stack Overflow