[英]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.