Reputation: 1524
I try this command :
Rscript "/Users/test/Scripts/arg_test.R" "path_in=/Users/test/GR/web-app/Rproject/Inputs/Rmerge/Description.csv" path_in2="/Users/test/IdeaProjects/Rproject/Inputs/Rmerge/Template_Auto.csv"
but I have this error : Error in parse(text = args[[i]]) : unexpected '/' in "path_in=/"
Part of Rscript :
args=(commandArgs(TRUE))
if(length(args)==0){
print("No arguments supplied.")
}else{
for(i in 1:length(args)){
eval(parse(text=args[[i]]))
}
}
path_out = "/Users/test/Rproject/Results/"
annotation = read.csv(paste(path_in, sep=""))
modules = read.csv(paste(path_in2, sep=""))
merge_output = merge(annotation, modules, by = "Module")
How can I define path_in as argument(args) ?
Thank you.
Upvotes: 1
Views: 1510
Reputation: 1524
Thank you, I just fix my problem !
I should use "path_in='/Users/test/...'" and not "path_in=/Users/test/...". Works fine with quote.
Rscript "/Users/test/Scripts/arg_test.R" "path_in='/Users/test/GR/web-app/Rproject/Inputs/Rmerge/Gene-level Description for Modules.csv'" "path_in2='/Users/test/IdeaProjects/Rproject/Inputs/Rmerge/Template_Auto.csv'"
Fix add by Dirk works fine too (thanks) !
Upvotes: 0
Reputation: 368639
Replacing the =
with the proper assignment operator <-
and protecting each argument with single quotes works for me:
Rscript /tmp/RscriptArgs.R \
'path_in<-"/Users/test/GR/web-app/Rproject/Inputs/Rmerge/Description.csv"' \
'path_in2<-"/Users/test/IdeaProjects/Rproject/Inputs/Rmerge/Template_Auto.csv"'
where /tmp/RscriptArgs.R
is what you showed from your script.
Upvotes: 1
Reputation: 360693
You have path_in=
inside the double quotes, but path_in2=
outside. Could this be the problem?
Upvotes: 0