Site icon R-bloggers

Plot the Scoring Streak of an NHL Player with R

[This article was first published on Data Twirling » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.