Run R script with start.process in .net

前端 未结 2 394
生来不讨喜
生来不讨喜 2020-12-06 03:38

I want to run an r script in vb.net which saves data in a .csv file. Till now i found the following approaches:

dim strCmd as String
strCmd = \"R CMD BATCH\"         


        
2条回答
  •  情歌与酒
    2020-12-06 04:32

    this is how it works for me:

            Dim myprocess As New Process
            myprocess.StartInfo = New ProcessStartInfo("C:\Program Files (x86)\R\R-2.6.2\bin\R.exe", "CMD BATCH C:/Users/test/test3.R C:/Users/test/testout.csv")
            myprocess.Start()
    

    second approach (first app. doesnt give me a good csv output so here this is a workaround):

        Dim proc = New Process
        proc.StartInfo.FileName = "C:\Program Files (x86)\R\R-2.6.2\bin\Rscript.exe"
        proc.StartInfo.WorkingDirectory = "C:\Program Files (x86)\R\R-2.6.2\bin"
        proc.StartInfo.Arguments = "C:/Users/Desktop/RtoVB/test4.r"
        proc.StartInfo.UseShellExecute = True
        proc.StartInfo.RedirectStandardOutput = False
        proc.Start()
    

提交回复
热议问题