繁体   English   中英

我正在尝试使用c#从asp.net页执行ar脚本,但未执行

[英]i am trying to execute a r script from asp.net page using c# but it's not executing

我使用过Rscript运行程序,但无法正常工作。

public static string SetupPath(string Rversion = "R-3.2.3")
        {
            var oldPath = System.Environment.GetEnvironmentVariable("PATH");
            var rPath = System.Environment.Is64BitProcess ?
            string.Format(@"C:\Program Files\R\R-3.2.3\bin\x64", Rversion) :
            string.Format(@"C:\Program Files\R\R-3.2.3\bin\i386", Rversion);

            if (!Directory.Exists(rPath))
                throw new DirectoryNotFoundException(
                  string.Format(" R.dll not found in : {0}", rPath));
            var newPath = string.Format("{0}{1}{2}", rPath,
                                         System.IO.Path.PathSeparator, oldPath);
            System.Environment.SetEnvironmentVariable("PATH", newPath);
            return newPath.ToString() ;
        }

此Button1_Click方法调用rscript运行程序。

        protected void Button1_Click(object sender, EventArgs e)
            {
                string s = SetupPath();
                string args = "";
                string r = @"D:\scr1.r";
                var RcodeFilePath = string.Format(@"D:\scr1.r", "R-3.2.3");

                //string c = RScriptRunner.RunFromCmd(RcodeFilePath, s);
                string c = RScriptRunner.RunFromCmd(r, "rscript.exe");
                Label1.Text = c;
            }

得到了解决方案..!

我在R中使用了“ Shiny”库。它将r脚本转换为应用程序,然后可以使用简单的http请求从asp.net对其进行调用。

暂无
暂无

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

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