Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想使用以下命令从 python 脚本执行 R 脚本:
subprocess.call("Rscript script.R --args arg1 arg2", shell=True)
我必须如何编写我的 script.R 才能使用 args?
像这样使用commandArgs:
commandArgs
args <- commandArgs(trailingOnly = TRUE) arg1 <- args[1] arg2 <- args[2] [...your code...]
还要确保Rscript可执行文件在您的PATH.
Rscript
PATH