Trends in run scoring, NL edition (more R)

July 17, 2012

(This article was first published on Bayes Ball, and kindly contributed to R-bloggers)

Last time around I used R to plot the average runs per game for the American League, starting in 1901. Now I’ll do the same for the National League.  I'll save a comparison of the two leagues for my next post.

A fundamental principal of programming is that code can be repurposed for different sets of datas. So much of what I’m going to describe recycles the R code I used for the AL exercise.

So starting with the preliminary step, I went back to Baseball Reference for the data, followed up by the same sort of finessing described for the AL. Once the data was read into the R workspace, I simply copies the AL code, and changed the variable names to create new objects and variables.  (I could have simply rerun the same code, but I wanted to have both the AL and NL data and trend lines available for comparison.)  This included creating new LOESS trend lines.

Read more »

To leave a comment for the author, please follow the link and comment on their blog: Bayes Ball. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Recent popular posts


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Dommino data lab

Quantide: statistical consulting and training



CRC R books series

Six Sigma Online Training

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)