This project is read-only.

Communicate or use R environment in C# project without installation

Jul 19, 2012 at 2:17 PM

Hi 

I want to develop application using R statistical computing and C# project. To have R Environment it is necessary to install the R-2.15.1-win.exe which will give me native DLLs installed with R environment.

Is there any way to have R Environment without doing any setup. i tried the below ways to get it work, but not happening

1) i copied all the dlls which comes with R-2.15.1 setup from "C:\Program Files\R\R-2.15.1\bin" to my project location and uninstalled the "R". but when i tried to execute the code, it is throwing exception 

public static void Main(string[] args)
        {
            REngine.SetDllDirectory(@"G:\R.Net\Binaries\x64");
            REngine.CreateInstance("RDotNet");
            REngine engine = REngine.GetInstanceFromID("RDotNet");
            string stFirsValue = "30/40";
            
            try
            {
                NumericVector x = engine.EagerEvaluate(stFirsValue).AsNumeric();
                Console.Write("FirstValue: " + stFirsValue + " = " + x[0].ToString());
            }
            catch (Exception objExp)
            {
                Console.Write(objExp.Message);
            }
            Console.Read();
        }
      

REngine.CreateInstance("RDotNet"); 

the second line throw "Object reference not set to the instance of an object."

2) i copied the whole files from "C:\Program Files\R\R-2.15.1" which include all bin and lib files to my location and used that path for REngine.SetDllDirectory method. but still it was not working.

how can do a manual installation, without running any setup. and create R environment into my project. so that i communicate with "R". registering R's COM DLL directly and start using them.

please suggest 

thanks in advance

sendil

 

Nov 14, 2012 at 11:57 PM

Please be very cautious in doing anything like that.

I know for a fact that it is against the law to include R binaries (files) in your project if the project is not Open Source and licensed under a GNU compatible license.

Now, if it is, i cannot guarantee that it is ok for you to do it, but i think you are allowed in that case, yes.

On the matter of how to do it, i am sorry i don't have the slightest idea. i just thought i'd give you a heads up on the legal matter

Nov 20, 2012 at 1:37 AM

Taking no account of license, you can achieve it.

Because in the R documents, R didn't need registry.

So using the R binary files, not by installation, is meaningful.

Nov 29, 2012 at 1:40 PM
Edited Nov 29, 2012 at 1:49 PM

@N1h1l1sT

This is not so simple. In some cases you are allowed to use GPLed apps in your commercial, closed source (proprietary) solutions. Read the license and FAQ (!) for GPL 2.

The key is:

  1. to communicate with the GPLed module in a specific way: by fork/exec and not to link your app with any DLLs or static libraries. Also you can employ a conception of a communicator. So you have to write your own "communicator" that loads R.NET (which loads R.DLL, so it's "touched" by GPL) but talks with your app through TCP/IP/shared files/webservices/database and other media. This is communication "at arm's length" (according to the FAQ) - and this is OK. 
  2. not to exchange complex data structures. This is unclear what the "complex" really means, but some commands, names of scripts to execute, files with results (XML, HTML, CSV) or some return values (through the mentioned communicator) should be OK
  3. your app should compile and run without the GPLed module (independence from the GPLed module). It's easy to achieve it with interfaces.
  4. not to distribute the GPLed module with your app (user installs it himself or you do it as a support)

 

Apr 28, 2014 at 12:53 PM
Sorry about restarting this discussion, but based on the current R.NET license, which appears to be a non-copyleft license. Can I assume that R.NET provides sufficient distance between my software and R, such that I can call R functions through the R.NET interface, without having to comply with the GPL license used for R, with respect to my own software?
so that:
  1. My software can be released only in binary form, with no obligation to provide source code (
  2. The R environment can be installed independently of my software
  3. I can provide the R.NET libraries as part of my software distribution (with the requisite copyright notice)
May 4, 2014 at 5:02 AM
I will start with disclaimers: I am not a lawyer, and did not influence the choice of license for R.NET. While I'll give my take on things, and think I understand where R.NET itself sits, I just cannot give a binding answer for your product. You should consider seeking advice from a qualified practitioner in law and/or intellectual property for your product.

@aoldevstat already gave a good concise summary of the situation. Also a related situation can be found in this discussion on Stackoverflow

Summarizing the sources of information, my understanding is:
  • Programs in the R language is considered by the R development team as data to the R engine, and not necessarily bound to be GPL compatible. Technically it may not be easy to close source R code, but in principle this is another matter than licensing.
  • If your R code depends on a third party (not R-Core) R package that is GPL-ed, well, I am not sure, but I'd assume you are bound by the GPL.
  • I understand that C# code that taps directly into the C-level R API is bound to be GPL-compatible; this is the case for R.NET itself.
The tricky situation for code using the R.NET library is whether your code can be considered as data, the way R code in the R console is considered as data (by the R-Core team anyway). It is probably the case for R statements (e.g. strings of R statements in C# code). I cannot guaranty that the rest of your C# code can be covered by a license that is non-GPL compatible; that is where professional legal advice is particularly warranted. I have no idea to what extent the statements in the GPL FAQ have been confirmed or not in court.

As an aside, considering what just wrote about R code being data, I just realize the package rClr may be more amenable to being used by non-GPL compatible package. I am not implying this is in replacement for R.NET; use cases addressed are different.

I hope this helps.
Feb 15, 2015 at 9:09 AM
Sendil wrote:
Hi  I want to develop application using R statistical computing and C# project. To have R Environment it is necessary to install the R-2.15.1-win.exe which will give me native DLLs installed with R environment. Is there any way to have R Environment without doing any setup. i tried the below ways to get it work, but not happening 1) i copied all the dlls which comes with R-2.15.1 setup from "C:\Program Files\R\R-2.15.1\bin" to my project location and uninstalled the "R". but when i tried to execute the code, it is throwing exception  public static void Main(string[] args) { REngine.SetDllDirectory(@"G:\R.Net\Binaries\x64"); REngine.CreateInstance("RDotNet"); REngine engine = REngine.GetInstanceFromID("RDotNet"); string stFirsValue = "30/40"; try { NumericVector x = engine.EagerEvaluate(stFirsValue).AsNumeric(); Console.Write("FirstValue: " + stFirsValue + " = " + x[0].ToString()); } catch (Exception objExp) { Console.Write(objExp.Message); } Console.Read(); }        REngine.CreateInstance("RDotNet");  the second line throw "Object reference not set to the instance of an object." 2) i copied the whole files from "C:\Program Files\R\R-2.15.1" which include all bin and lib files to my location and used that path for REngine.SetDllDirectory method. but still it was not working. how can do a manual installation, without running any setup. and create R environment into my project. so that i communicate with "R". registering R's COM DLL directly and start using them. please suggest  thanks in advance sendil  
Hi Sendil,
I have a similar requirement and exploring Rdot net as an option. I am very new to RdotNetect and struggling to get some know hows to build my C# proj.

I need to call R scripts from my C#/ASP.net page connected to ms sql server via RDotNet library and build a dashboard for my application. I am looking for some step by step guidance to achieve the same. I have tried to refer the articles available on internet but somehow, did not get the correct path. please help me with some suggestions.
Sincere thanks in advance