Visualize Baseball with sunburstR"

knitr::opts_chunk$set(echo = TRUE, warning=FALSE, message=FALSE)

Sunburst charts from [`sunburstR`](https://github.com/timelyportfolio/sunburstR) work well in sports. Let's look at a couple of simple examples of interactive sunburst visualizations with baseball data. We'll be using [`pitchRx`](https://github.com/cpsievert/pitchRx) from [Carson Sievert \@cpsievert](https://twitter.com/cpsievert) to scrape baseball game data. To replicate these examples, please install any missing packages you see in the following code. wzxhzdk:1 ### Make the Data sunburst-able wzxhzdk:2 ### Create a Sunburst wzxhzdk:3 ### Use Sunburst Events In this [commit](https://github.com/timelyportfolio/sunburstR/commit/7f6879f779d0062699f758795231ecdcd9465777), we added some basic event dispatch to `sunburstR` that can be used in Shiny and non-Shiny contexts. We will use it to display a link to the games that fit the hovered paths. wzxhzdk:4 ## Sequence of Pitches [Dan Malter](http://danmalter.github.io/) wrote a fantastic post [Using Markov Chains to Predict Pitches](http://danmalter.github.io/r/2016/03/28/Markov-chains.html). Let's visualize his pitch data for Jake Arrieta. ### Scrape the Data wzxhzdk:5 ### Draw the Sunburst wzxhzdk:6 ## Thanks Thanks so much to [Kerry Rodden](https://twitter.com/kerryrodden) who provided the original [sunburst](http://bl.ocks.org/kerryrodden/7090426) on which this is based. Thanks [Mike Bostock](https://bost.ocks.org/mike/) for [d3.js](https://d3js.org) (*please give us a way to pay you*). Thanks [Tim Holman](http://tholman.com/) for the great [github-corners](http://tholman.com/github-corners/). Thanks [skeleton](http://getskeleton.com/). Thanks Carson Sievert for `pitchRx` and all your work on [`plotly`](https://github.com/ropensci/plotly). Thanks Dan Malter for the great markov pitch post.


Try the sunburstR package in your browser

Any scripts or data that you put into this service are public.

sunburstR documentation built on Feb. 16, 2023, 6:37 p.m.