Monday, December 13, 2010
Creating Baseball Graphics Using RPosted by Ricky Zanker
Ever wanted to create "heat maps" like this. Or line graphs like this. Now here's you chance!
These graphics are made through the freely available software simply called R. A powerful software used by scientists, R can be a daunting program to use with its command-line interface that might not be too friendly to those who are justing getting by with Microsoft Excel. Plus there is a lot of code to learn in order to do the most basic functions. I am certain there are many people out there who are willing to learn how to make these graphics with R but they don't know where to start. This is where I come in.
Starting this week, I will write a series of tutorial articles here at THT Live explaining how to use the R system, import data, write code, and make those awesome graphics. Most of the graphs and functions I will use will pertain to the very popular pitch f/x from MLB Advanced Media. A large amount of pitch f/x data is easy to come by now using the awesome web tool by Joe Lefkowitz so no database required. Also note that the series is not called "Pitch f/x Graphics" since I will try to find some things to do that don't involve pitch f/x data. Another thing to note is that I am no R expert and I have only used it for baseball data. There may be easier ways to do certain things. But this also means that I shouldn't be too overly complicated either. If you have any ideas of what I should cover over the course of the series, please comment away or shoot me an email.
Before you leave, let's start with the most basic step of this process by downloading the R software. Go to http://cran.r-project.org/ and click your Operating System (I will be using Windows). For Windows users, click the base package. Mac users, click the file named R-2.12.0.pkg. And if you are using Linux, download the tar.gz file on the homepage. After the file is downloaded, follow the instructions for installation. And now your done.
For next time, I will go over the basic interface of the R software and how to download packages.
Ricky Zanker also writes for Draysbay and can be contacted by email.