[英]Executing an R-script via C#
To execute an R-script automaticaly I must type the following in cmd.exe: "C:\Program Files\R\R-4.1.2\bin\Rscript.exe" "T:\R\Erste_Versuche.R" (Must be written exactly like this)要自动执行 R 脚本,我必须在 cmd.exe 中键入以下内容: "C:\Program Files\R\R-4.1.2\bin\Rscript.exe" "T:\R\Erste_Versuche.R"完全像这样写)
The following code already worked with.txt- and.exe -files:以下代码已用于 .txt 和 .exe 文件:
string command = @"C:\...\test.txt";
Process.Start("cmd.exe", "/c" + command );
Running the following unfortunately does not execute what happens when I type the same manually into cmd.exe不幸的是,当我在 cmd.exe 中手动输入相同内容时,运行以下命令不会执行
string command = @"C:\Program Files\R\R-4.1.2\bin\Rscript.exe";
Process.Start("cmd.exe", "/c" + command );
Q1: Why does "C:\Program Files\R\R-4.1.2\bin\Rscript.exe" not get executed? Q1:为什么“C:\Program Files\R\R-4.1.2\bin\Rscript.exe”没有执行?
Q2: How to to insert "C:\Program Files\R\R-4.1.2\bin\Rscript.exe" "T:\R\Erste_Versuche.R" correctly into cmd.exe? Q2:如何将“C:\Program Files\R\R-4.1.2\bin\Rscript.exe”“T:\R\Erste_Versuche.R”正确插入cmd.exe?
Here is a working code:这是一个工作代码:
string command = @"T:\R\Erste_Versuche.R";
Process.Start(@"C:\Program Files\R\R-4.1.2\bin\Rscript.exe", command);
Thank you so much Mofi .非常感谢莫菲。 For leading me to an easier solution but also explaining how my complicated approach could have worked.
引导我找到一个更简单的解决方案,同时也解释了我的复杂方法是如何工作的。
I decided to use R because it was so much easier for me to visualise the data I have.我决定使用 R,因为它更容易可视化我拥有的数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.