Plot the Scoring Streak of an NHL Player with R

April 1, 2011

(This article was first published on Data Twirling » R, and kindly contributed to R-bloggers)

I am a big Boston Bruins fan and have enjoyed the ups and downs over the last few years, regardless of the catastrophes that have occurred during the playoffs.  The team struggled a few weeks ago, but have recently seemed to find their stride.

During that time frame, in my opinion Nathan Horton was a significant factor in those wins. For a long chunk of the season though, it felt like he was in a rut.   It got me thinking about how we could actually use some data to see how “streaky” a player is.  In this case, Nathan Horton.

The code below uses R to collect what we need from the web and plot the cumulative goals over the course of a season. Each dot on the line should represent a game, so it is easy to view games played versus production across each season of a career.

A big thank you to @Bernd on  stackoverflow for his help and Hadley for making some great R packages.  Also, I am starting to warm up to R Studio and think its a great tool for those coming from software like SAS or SPSS..

Resulting plot:

To leave a comment for the author, please follow the link and comment on their blog: Data Twirling » R. 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...

Tags: ,

Comments are closed.

Search R-bloggers


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)