Archives for posts with tag: MLB

I recently presented my research to the Statistical Graphics Group here at Iowa State. It was a shameless self-promotion of my R package, pitchRx, which makes Major League Baseball’s PITCHf/x data easier to obtain and analyze. People went crazy over the real-time animations in my presentation slides, so I thought I would give a straight-forward tutorial on how to make your own!

First of all, make sure you have R (version 2.15.1 or newer), R-studio and pandoc installed on your machine. I’ve provided a screenshot of the real_time.Rmd file below which produces other files which are necessary for the animations. The code in this (R Markdown) file depends on several R packages, so make sure you have the required packages installed before knitting this file:

(1) devtools

(2) knitr

(3) R2SWF

Once the proper packages are installed, make sure you have a internet connection and click on the “Knit HTML” feature in R-studio.

Once the knitting process has finished, this creates both a markdown and HTML file in your working directory. After these files are created, open your favorite command-line interface and:

(1) Mimic your current directory to the directory you are using in R-studio

(2) Enter the following command: pandoc -s -S -i -t dzslides -o real_time.html

Now open real_time.html in a web browser…and Voliá! Note that these slides can be viewed with any browser that supports HTML5. If your browser doesn’t support HTML5, go out and get yourself a real browser

You can easily customize this code to animate any set of pitches that you might be interested in. Just edit the dates and player(s) in the scrapeFX() function. You also probably want to consider subsetting the FX dataframe according to which pitch types you want. It’s that easy! If you think this is really cool and want to know more, just be patient and be on the look out for a formal paper 🙂


I’ve decided to start a blog on WordPress as motivation to have more of a web presence. The real driving force though was Mike Fast’s post on how to build a (MLB) pitch database. I plan on building my own database before summer hits and using it to discover some new visualizations and statistical analyses of the MLB pitch f/x data. Also, be on the look out for an update to my academic website: