Possible Duplicate:
how to communicate with R through VBnet( or C#)
I want to generate a random number from log-normal and triangular distribution in VB.NET.
To do so I thought of integrating R with VB.NET. I added following reference to R,
STATCONNECTORCLNTLib;
StatConnectorCommonLib;
STATCONNECTORSRVLib;
My questions:
- is there anything else that I need to do to use R in VB.NET
- How can I use R commands in VB.NET?
Thanks!
Using R from .NET
You can find an example on how to use R from .NET here:
http://www.codeproject.com/Articles/25819/The-R-Statistical-Language-and-C-NET-Foundations
It is written for C#, but I think it’s easy to translate to VB.NET.
The most important thing seems to be initalizing which is done by:
After this you can use the
sc1object to evaluate symbols etc.Alternative: Random number generator library for .NET
However if I may make a suggestion. Why not use a random number library for .NET like this one?
http://www.codeproject.com/Articles/15102/NET-random-number-generators-and-distributions
It contains both log-normal and triangular distribution, so it should fit your need and you don’t need to have R installed. It will probably faster also because it’s a native .NET library.