Rscript:将路径文件定义为参数
我尝试这个命令:
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"
但我有这个错误: parse(text = args[[i]]) 中的错误:
Rscript 的“path_in=/”部分中出现意外的“/”:
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")
如何将 path_in 定义为参数(args)?
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
用正确的赋值运算符
<-
替换=
并用单引号保护每个参数对我来说很有效:其中
/tmp/RscriptArgs.R
是您从脚本中显示的内容。Replacing the
=
with the proper assignment operator<-
and protecting each argument with single quotes works for me:where
/tmp/RscriptArgs.R
is what you showed from your script.双引号内有
path_in=
,但双引号内有path_in2=
。这可能是问题所在吗?You have
path_in=
inside the double quotes, butpath_in2=
outside. Could this be the problem?谢谢,我刚刚解决了我的问题!
我应该使用“path_in='/Users/test/...'”而不是“path_in=/Users/test/...”。
与报价一起工作正常。
由 Dirk 修复的 add 也可以正常工作(谢谢)!
Thank you, I just fix my problem !
I should use "path_in='/Users/test/...'" and not "path_in=/Users/test/...".
Works fine with quote.
Fix add by Dirk works fine too (thanks) !