使用命令提示符将参数传递给R

时间:2016-10-21 07:27:10

标签: r cmd parameter-passing rstudio

我正在尝试使用参数在cmd中运行我的Rscript(.r文件),但这不起作用。我想添加两个数字并显示它们的结果,所以为此我在cmd中传递了两个我想要执行的数字 这是我的文件cat1.R

library(getopt)
print("hello")
args <- commandArgs(trailingOnly = TRUE)
rnorm(n=as.numeric(args[1]), b=as.numeric(args[2]))
c = n + b
print(c)

这是在cmd中执行cat1.R的命令

C:\Users\ypoint\Downloads>Rscript cat1.R 5 100

它给我一个错误

'Rscript' is not recognized as an internal or external command,
operable program or batch file.

对此的任何帮助都将非常感谢。谢谢

0 个答案:

没有答案