简体   繁体   English

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

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

I have used Rscript runner but its not working. 我使用过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() ;
        }

This Button1_Click method calls the rscript runner. 此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;
            }

Got the solution..! 得到了解决方案..!

I used "Shiny" a library in R. This converts the r script into an app which can then be called from asp.net using simple http request. 我在R中使用了“ Shiny”库。它将r脚本转换为应用程序,然后可以使用简单的http请求从asp.net对其进行调用。

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

相关问题 使用C#在asp.net页中无法正确执行SqlDataReader - SqlDataReader not executing correctly in asp.net page using C# 我正在尝试使用asp.net C#每月自动填充报告 - I am trying to auto populate the report monthly using asp.net c# 如何从ASP.NET C#运行R脚本 - How to Run R Script from ASP.NET C# 我无法从Excel文件中读取并使用C#中的asp.net存储到数据库中? - I am not able to read from Excel file and store into database using asp.net in c#? 我正在使用 asp.net Z240AA2CEC4B29C56F3BEE520A8DCEE7 从 gridview 创建 pdf - I am creating pdf from gridview using asp.net c# iTextSharp but Turkish characters are not visible 我正在尝试在 asp.net c# 中使用 google API 发送 email 并收到错误 400 redirect_uri_mismatch - I am trying to send email using google API in asp.net c# and getting Error 400 redirect_uri_mismatch 从ASP.NET网页使用C#文件 - Using C# file from an ASP.NET web page 我试图从我的SQL语句的下拉菜单中使用selectedItem来填充C#asp.net中的文本框 - I am trying to use a selectedItem from a drop down menu in my SQL statement to populate a textbox in C# asp.net ASP.Net C#在重定向页面上执行JavaScript函数 - ASP.Net C# execute JavaScript function on redirected page 似乎无法从asp.net C#简单执行PowerShell脚本 - Can't seem to do a simple execute of PowerShell script from asp.net C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM