I'm trying to pass a list of elements as an argument to an R script.
R -f myscript.R --people "James" "John" "Emily" "Anna"
I'm trying to make use of the optparse library to try and do the same as this answer which uses the argparser in python.
CodePudding user response:
I think optparse accepts only one argument for each "flag". I would use a comma-separated list:
R -f myscript.R --people James,John,Emily,Anna
And in your script you get the character string "James,John,Emily,Anna" that you can split with strsplit to get the vector of names.
