how to communicate with R through VBnet( or C#)

穿精又带淫゛_ 提交于 2019-12-01 06:28:47

I'd suggest you try R.NET. The blurb says:

R.NET enables .NET Framework to collaborate with R statistical computing. R.NET requires .NET Framework 4 and native DLLs installed with R environment. You need no other extra installations. Enjoy statistics and programming in your special language with R.

It is an open source binding that seems a bit simpler than the statconn tools, since it doesn't go through DCOM. LGPL licensed, so free for commercial use too. And you can combine with Excel-DNA to expose R via .NET to Excel - some discussion here: http://www.r-bloggers.com/yet-another-way-to-use-r-in-excel-for-net-programmer/.

An alternative to both statconn, and R.Net is to use the mt4r dll and simply drop the cMT4R C# class into your project and start using R. I have used statconn and still often do for speed of passing data. I never figured out R.Net.

But if you are trying to get up and running with the simplest possible installation, take a look at the following link that describes the interface and the installation for MT4R. After including the C# class in your project, you simply have to update the class with your computer's R path and the DLL will do the heavy lifting. The class interface is intuitive and simple to use.

https://sites.google.com/site/marketformula/vb6-to-c/vb6-to-c-downloads/calling-r-from-csharp-dotnet

There is also a VB6 class available (linked in the post above) if anyone is still kicking around on VB6 or uses VBA and wants a way to get up and running with R quickly with an easy installation.

A simple demo application is included that shows how to send and receive data from C# to R.

For this purpose user StatConn DCOM library instead of R.NET. In my own experience it is much more stable than the .NET library.

In order to do this you need to install R, add extensions rcom and rsproxy from any CRAN repository and install StatConn DCOM. Once these are installed you may check to see if your R connection is working via those sample programs come with the DCOM package.

If these are working you may add all statconn references to your .NET project via Visual Studio.

Good luck

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!