Calling R from F#
August 27, 2013 Leave a comment
So I thought I would check out R.NET so I downloaded R from its home site. I then created a basic F# library and installed R.DotNet. I found it amusing that it installed from the recycle bin:
I then fired up a F# project to test it out. I decided to mimic the C# example on the Codeplex site in F#. I gopt to the 4th line where I actually tried to create an instance of the REngine:
So I typed into Google R and F# and what do you know, some folks created a type provider for R How cool is that? I installed the RProvider from NuGet and then typed in the basic code sample but it was not getting recognized.
I then read in the documentation that you need to restart Visual Studio (good to know) and make sure that the .NET version is 4.5. Still no luck. I then downloaded the example script that is on Github and I was getting the same problem. Out of desperation, I hit F6 and I got this:
Then all of the R type provider references resolved. I then changed the R.Net to point at the bin and all of those references resolved. I then commented out
- //open RProvider.tseries
- //open RProvider.zoo
and
- //let adf = R.adf_test(msft)
and no more red squiqqley! When I hit F6 though, I get this:
Undaunted, I ran the script anyway and sure enough, I got some output: