Executing R script programmatically

后端 未结 5 850
臣服心动
臣服心动 2020-12-09 18:31

I have a C# program that generates some R code. Right now I save the script to file and then copy/paste it into the R console. I know there is a COM interface to R, but it d

5条回答
  •  鱼传尺愫
    2020-12-09 18:53

    Here is a simple way to achieve that,

    My Rscript is located at:

    C:\Program Files\R\R-3.3.1\bin\RScript.exe

    R Code is at :

    C:\Users\lenovo\Desktop\R_trial\withoutALL.R

     using System; 
     using System.Diagnostics; 
     public partial class Rscript_runner : System.Web.UI.Page
                { 
                protected void Button1_Click(object sender, EventArgs e)
                    {
                     Process.Start(@"C:\Program Files\R\R-3.3.1\bin\RScript.exe","C:\\Users\\lenovo\\Desktop\\R_trial\\withoutALL.R");
            }
                }
    

提交回复
热议问题