Mathias Brandewinder on .NET, F#, VSTO and Excel development, and quantitative analysis / machine learning.
by Mathias 14. April 2013 12:20

Last Thursday, I gave a talk at the Bay.NET user group in Berkeley, introducing F# to C# developers. First off, I have to thank everybody who came – you guys were great, lots of good questions, nice energy, I had a fantastic time!

My goal was to highlight why I think F# is awesome, and of course this had to include a Type Provider demo, one of the most amazing features of F# 3.0. So I went ahead, and demoed Tomas Petricek’s World Bank Type Provider, and Howard Mansell’s R Type Provider – together. The promise of Type Providers is to enable information-rich programming; in this case, we get immediate access to a wealth of data over the internet, in one line of code, entirely discoverable by IntelliSense in Visual Studio - and we can use all the visualization arsenal of R to see what’s going on. Pretty rad.

Rather than just dump the code, I thought it would be fun to turn that demo into a video. The result is a 7 minutes clip, with only minor editing (a few cuts, and I sped up the video x3 because the main point here isn’t how terrible my typing skills are). I think it’s largely self-explanatory, the only points that are worth commenting upon are:

  • I am using a NuGet package for the R Type Provider that doesn’t officially exist yet. I figured a NuGet package would make that Type Provider more usable, and spent my week-end creating it, but haven’t published it yet. Stay tuned!
  • The most complex part of the demo is probably R’s syntax from hell. For those of you who don’t know R, it’s a free, open-source statistical package which does amazingly cool things. What you need to know to understand this video is that R is very vector-centric. You can create a vector in R using the syntax myData <- c(1,2,3,4), and combine vectors into what’s called a data frame, essentially a collection of features. The R type provider exposes all R packages and functions through a single static type, aptly named R – so for instance, one can create a R vector from F# by typing let myData = R.c( [|1; 2; 3; 4 |]).

That’s it! Let me know what you think, and if you have comments or questions.

Comments

4/14/2013 7:06:28 PM #

Bohdan Szymanik

How does the R provider enable loading libraries? It'd be great to use ggplot from F#...

Bohdan Szymanik New Zealand | Reply

4/15/2013 6:01:19 AM #

Mathias

Hi Bohdan,
You can find more explanations on the "how" at the R Provider GitHub page: github.com/.../wiki
If you are specifically talking about how to load a R package, for packages that are not part of the basic R distribution, you have to install the package from R itself first. Once the package is installed, the Type Provider will give you access to it directly afterwards.
And regarding ggplot, I am hearing a rumor that something might be happening in a future not too far...
Cheers,
Mathias

Mathias United States | Reply

4/15/2013 9:15:44 AM #

Bohdan Szymanik

I'll stay tuned!

Bohdan Szymanik New Zealand | Reply

7/17/2013 8:59:15 AM #

trackback

F# Type Provider for MATLAB - Feedback requested, contributions welcome

Rick Minerich ( @rickasaurus ) of Bayard Rock has implemented an F# Type Provider for MATLAB (TM) . A

Don Syme's WebLog on F# and Related Topics | Reply

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading



Comments

Comment RSS