1

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.

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

You have path_in= inside the double quotes, but path_in2= outside. Could this be the problem?

Comments

0

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) !

3 Comments

Good to see you have it fixed. It is typical for someone who asked a question to then 'accept' an applicable answer, if one is given, rather than to provide another answer. So you may want to pick one here.
I choose your fix (just add my fix to add another way to correct this bug).
Merci bien --- And I didn't even suggest littler as an Rscript replacement ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.