I’m writing a console app in C#, and I’d like to use the R engine to pop up a graph in a window.
Does anyone know if this is possible from Visual Studio 2012?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To pull a graph from R into .NET, and display it on a WinForms panel:
First, we have to install Statconn, which is the bridge between .NET and R. Its important to install the correct version (it won’t work if there is the wrong mix of x32 and x64). The easiest way to ensure this is to install Statconn from within the R console:
At this point, it will give an error that you don’t have the
Statconnlibrary installed. This is easy to fix:This will automatically install the correct version of the StatConn bridge, which is a standalone windows installer.
Now that we have installed Statconn, we can open up the sample .NET project in
C:\Program Files (x86)\statconn\DCOM\samples\Graphics.NET. This sample .NET project shows how to use R to plot graphics from within a C# WinForms project.p.s. There is also other sample code for Python, C++, VBS, jscript, etc.
Update
If you cannot get this working, try
R.Net, which is probably a better choice because Statconn hasn’t been updated in a while, and is quite picky with less than perfect mixtures of ’32-bit’ / ’64-bit’ / ‘supported R versions’.