【发布时间】:2013-11-16 01:48:06
【问题描述】:
我用
从 shell 命令行调用脚本r CMD BATCH myscript.R
我必须在 myscript.R 中做什么才能获得带有脚本名称的字符向量(即“myscript.R”)?
注意:
我发现了许多关于类似主题的问题,但找不到任何适合我的东西。特别是从问题Determine path of the executing script我得到了修改后的脚本sn-p:
args <- commandArgs(trailingOnly = F)
scriptPath <- sub("^--file=", "", args[grep("^--file=", args)])
但scriptPath 始终为空(可能是由于我通过 BATCH 命令调用脚本的方式)。
【问题讨论】:
标签: r batch-file filepath