Read my book

I wrote books about Webpack and React. Check them out!

Saturday, September 11, 2010

A Quick Peek at R - a Statistical Computing Platform and Language

I had a nice change to learn a bit of R this week as I took an intensive course on it. R is an environment and a language for statistical computing and graphics. It's open source (GPL) and fairly widely used as far as I know.

I ended up using RKWard frontend. I didn't have any particular reason for picking it amongst the others but in retrospect it wasn't that bad a choice.

In this post I'm going to show you some tricks I learned and share some resources on R. Reading it won't make you an R guru but will probably get you on the right way should you decide to become one.



Very Basics of R

As mentioned in the introduction R is both an environment and a language. It has some goodies that are particularly useful for statistics. You will find an interesting little language inspired by Scheme in the core.

The language is meant to be programmed mostly in functional manner. It does have some OOP and imperative characteristics, however. I guess functional approach is somewhat natural for crunching statistics.

The language provides various types including scalars, vectors, martices and such [1]. Interestingly lists in R are actually associative arrays (think "dictionary" in Python).

I found it really cool that the language provides vectors and matrices by default. The syntax it provides for manipulation is somewhat awesome too. Consider this code:



Note how imaginative particularly index selectors are! I really like this aspect of the language.

Plotting

It's ridiculously easy to plot something in R. Just consider following examples:



See R Graph Gallery for more inspiration.

Conclusion

The examples shown cover just a fraction of what R has to offer. Even if you are not into statistics it's well worth a look. If you are interested in R, consider checking out the following resources: