i am using the preinstalled package RScript in R.
I want to call the following R-Script with the name 'test.R' from the command prompt:
a <- c("a", "b", "c")
a
args <- commandArgs(TRUE)
b <- as.vector(args[1])
b
I use the following command:
RScript test.R c("d","e","f")
This creates following output:
[1] "a" "b" "c"
[1] "c(d,e,f)"
As you see, the first (and only) argument is interpreted as a String, then converted to a 1-dimensional vector. How can the argument be interpreted as a vector?
Sidenote: Of course the items of the vector could be separated into several arguments, but in my final project, there will be more than one vector-argument. And to implement something like this is my last resort:
RScript test.R "d" "e" "f" END_OF_VECTOR_1 "g" "h" "i" END_OF_VECTOR_2 "j" "k" "l"