简体   繁体   English

从Powershell运行R脚本

[英]Run R script from Powershell

In batch script, I can run an R script with the following syntax: 在批处理脚本中,我可以使用以下语法运行R脚本:

Rterm.exe --quiet --slave --vanilla < "C:\some_script.R"

However, Powershell seems to have reserved "<" for future expansion. 但是,Powershell似乎已经为未来的扩张保留了“<”。 I am wondering if there is a direct way to run R script within another Powershell script. 我想知道是否有一种直接的方法在另一个Powershell脚本中运行R脚本。

You should probably look Rscript instead of redirection -- this would become 你应该看看Rscript而不是重定向 - 这会变成

Rscript.exe C:\someScript.R

where you can add the usual options. 你可以在哪里添加常用选项。

最简单的方法可能是将它包装在对cmd.exe的调用中:

cmd.exe /C "Rterm.exe --quiet --slave --vanilla < `"C:\some_script.R`""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM