我使用过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;
}
答案 0 :(得分:1)
得到解决方案..!
我在R中使用了“Shiny”库。 这会将r脚本转换为app,然后可以使用简单的http请求从asp.net调用。