Jan 8, 2015 at 3:26 PM
Hi R.Net guys

After downloading and installing the last release of R.Net I try to create multiple instances of REngine in order to realise many parallelized computation with R (An Rengine in each C# thread).

However, I have problem I think the new version allow us to get some REngine instances but each instance seems using the same R session so impossible to use parallelized computation. Hence my test code:

REngine.SetEnvironmentVariables(); // <-- May be omitted; the next line would call it.
            var engine = REngine.GetInstance();
            var engine2 = REngine.GetInstance();
            engine.Initialize(); engine2.Initialize();
            engine.Evaluate("a <- 1");
            var a = engine.GetSymbol("a").AsInteger();
I hope some body can help me.

Thank you for your time.
Jan 8, 2015 at 6:29 PM
TL;DR - You can't have multiple R engines with a single R.Net process.

In R.Net the unmanaged R dlls get loaded into the process and there currently isn't a way to load R as a separate process and setup some sort of IPC mechanism. We've been talking about how to do that, but it just doesn't exist yet. You can run your process in parallel so that R.Net is hosted in each of your processes.

An approach that works with R.Net without having to grapple with process management is to use the "snow" and "foreach" packages from CRAN. You'll find quite a few tutorials and examples on Google that work pretty well. I've only tinkered with it for my own amusement, so I can't add much in the way of helpful advice.

Blue Skies,
Jan 9, 2015 at 9:02 AM
Thant you skyguy94 for your reply and your advices, I understand why my test code does not work. I will look "snow" and "foreach" as you advised me.