Reputation: 4899
I have, in one hand, a plateform I developped in R, composed of many user-defined functions used to produce a report, using as inputs matrices and arguments.
In an other I manage my data flow through a c#
Platform.
What I want to do is calling my R
Platform from c#
: calling a function defined in an Rdata
file into my c#
code (which handle all my data matrices).
I am familiar with RdotNet
and use it to call user defined functions, but these are functions defined in my c#
code itself, while I need to call functions in a Rdata
file.
Thanks in advance.
Upvotes: 0
Views: 1107
Reputation: 1554
R functions called from R.NET are not restricted to ones created from strings in .NET. If you define and save the function definition in R:
f <- function() {"Hello World"}
save(f, file='f.RData')
Then in C# you simply do something like
static void stackoverflow_27924923_2752565 (REngine engine)
{
engine.Evaluate ("load('~/f.RData')");
var s = engine.Evaluate ("f()").AsCharacter()[0];
Console.WriteLine(s);
}
Upvotes: 2