Reputation: 57
I have an R source file.
I want to execute the code in that file within my C# app.
The .R
file has a function that looks like this:
How can I execute the .R
file from my console app and pass in the parameters for the function?
Upvotes: 1
Views: 223
Reputation: 530
You can invoke the script file with your application.
http://jmp75.github.io/rdotnet/
engine.Evaluate("source('c:/src/path/to/myscript.r')");
Upvotes: 0
Reputation: 1332
You can use rdotnet(R.NET)
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.
REngine.SetEnvironmentVariables();
REngine engine = REngine.GetInstance();
engine.Initialize();
//string path = "\HelloWorld.r";
//engine.Evaluate("source('" + path + "')");
var x = engine.Evaluate("x <- 1 + 2");
Upvotes: 1