Tag: r

REngine’不包含’SetDllDirectory’,’RDotNet的定义

我的代码 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using RDotNet; using RDotNet.Devices; using RDotNet.Internals; using Microsoft.Win32; namespace Con_R { class Program { static void Main(string[] args) { string rhome = System.Environment.GetEnvironmentVariable(“R_HOME”); if (string.IsNullOrEmpty(rhome)) rhome = @”C:\Program Files\R\R-3.3.1″; System.Environment.SetEnvironmentVariable(“R_HOME”, rhome); System.Environment.SetEnvironmentVariable(“PATH”, System.Environment.GetEnvironmentVariable(“PATH”) + “;” + rhome + @”binx64″); // […]

在c#/ rdotnet中实现交互式R控制台?

我正在使用rdotnet将统计处理添加到C#应用程序,这看起来非常适合我们当前的需求。 基本上,应用程序生成许多不同的时间序列,我们使用R来计算分布,分位数等。 如果我们可以向应用程序添加交互式R控制台,那么未来版本的好处就是如此,以便用户可以对应用程序环境中的数据执行进一步的临时处理。 最初的研究没有抛出任何指针或例子。 有谁能提出前进的方向? 谢谢。

C#没有使用RDotNet连接到R.

我正在尝试使用RDotNet将C#连接到R. 下面的代码是希望R计算两个数字的总和,并希望C#得到结果并在命令窗口中显示它。 using System; using RDotNet; namespace rcon { class Program { static void Main(string[] args) { string dllPath = @”C:\Program Files\R\R-3.1.0\bin\i386″; REngine.SetDllDirectory(dllPath); REngine.CreateInstance(“RDotNet”); //REngine engine = REngine.GetInstanceFromID(“RDotNet”); using (REngine engine = REngine.GetInstanceFromID(“RDotNet”)) { var x = engine.Evaluate(“x <- 1 + 2"); Console.WriteLine(x); } } } } 但是当我尝试将命令发送到R并在x中返回calue时出现错误: “InvalidOperationException未处理” “由于对象的当前状态,操作无效。” 如果我探索对象“引擎”,我看到IsRunning=false 。 这可能是问题吗? 我怎样才能解决这个问题,以便能够与R接口?

在C ++中部署GBM模型| 让Predict.gbm在R之外工作

有没有办法将gbm模型导出到C ++。 具体来说,如何调用predict.gbm函数在R外部运行以获取新数据集。 我已将模型导出为PMML文件,但我不确定新数据集将如何根据PMML进行分数。 我是R的新手,花了很多时间试图弄清楚这一点无济于事,并会欣赏任何线索 提前致谢

如何让ExcelDNA与R.Net一起使用

我是一名C#和R初学者试图运行示例http://mockquant.blogspot.com/2011/07/yet-another-way-to-use-r-in-excel-for.html <![CDATA[using System; using System.Collections.Generic; using System.Linq; using System.Text; using ExcelDna.Integration; using RDotNet; namespace CSLib { public class CSLib { static REngine rengine = null; static CSLib() { // Set the folder in which R.dll locates. REngine.SetDllDirectory(@"C:\Program Files\R\R-2.13.0\bin\i386"); rengine = REngine.CreateInstance("RDotNet", new[] { "-q" }); } [ExcelFunction(Description = "get random numbers obey to normal distribution")] […]

R脚本formsC#。 传递参数,运行脚本,检索结果

我想知道是否可以在传递值列表时运行Rscript,让R脚本运行,然后将重新分配的值列表输出回c#。 我见过人们说R.N​​ET很好但是我只看到过使用它直接创建值,操作它们,访问它们等等的例子,当我想要做的是运行已经创建的脚本来接收数据时,处理它并返回数据。 我也知道我可以用csv文件做到这一点但重点是我想切出中间人。

是否可以在OSX上以Mono或.NET从Unity C#运行R代码?

有没有办法在Mono中使用Unity的C#运行R脚本? 如果没有办法使用Mono运行R脚本,我愿意使用.NET 更新 因此,以下代码将调用R脚本,但如果从unity monodevelop调用则不会输出文件。 将字符串返回到mono是可以的,但是在startInfo.UseShellExecute和startInfo.RedirectStandardOutput上更改true和false会引发错误。 以下是将调用R代码的C#代码: System.Diagnostics.Process process = new System.Diagnostics.Process(); System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; startInfo.FileName = “Rscript”; startInfo.WorkingDirectory = Application.dataPath + “/myUnity/Scripts/”; startInfo.Arguments = “Rexp1.R”; startInfo.CreateNoWindow = true; startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.UseShellExecute = true; startInfo.RedirectStandardOutput = false; process.StartInfo = startInfo; process.Start(); 我确信R脚本会输出一个文件,或者我可以抓住stdout并保持它。 我将很高兴输出到文件或具有统一允许返回的字符串是R脚本的输出。 更新2 * – 这是R脚本。 sink(“output.txt”) nts […]

从asp.net应用程序运行R脚本并从r获取输出

我需要运行存储在我的asp.net应用程序的文件夹中的ar脚本,并在网页中显示该r脚本的输出。 下面是我的Default.aspx.cs文件的代码 using RDotNet; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } private static double EvaluateExpression(REngine engine, string expression) { var expressionVector = engine.CreateCharacterVector(new[] { expression }); engine.SetSymbol(“expr”, expressionVector); // WRONG — Need to […]

如何通过VBnet(或C#)与R通信

最近,我用VB.net开发了一个实验应用程序(在Windows平台上),当应用程序收集数据时,我想用R来分析数据,但我不知道如何与R通信 (换句话说, 我想在我自己的应用程序中将R脚本发送到R )。 如果有人能给我一些建议或一些参考文件,我将不胜感激。 非常感谢你!

如何要求套接字等待更多数据的到来

我正在玩RserveCLI项目,这是一个与统计环境R通信的.net客户端。基本思想是通过TCP协议在此.NET客户端和R会话之间发送数据/表彰。 其他人和我发现的一个错误就是大数据中继,比如超过10k字节,无法成功传输。 我在下面的代码片段中找到了但是: // send the commend to R, then R will do some computation and get the data ready to send back int toConsume = this.SubmitCommand(cmd, data); var res = new List(); while (toConsume > 0) { var dhbuf = new byte[4]; if (this.socket.Receive(dhbuf) != 4) { throw new WebException(“Didn’t receive a header.”); } […]