<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.2">Jekyll</generator><link href="https://williazo.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://williazo.github.io/" rel="alternate" type="text/html" /><updated>2022-12-21T08:44:31-08:00</updated><id>https://williazo.github.io/feed.xml</id><title type="html">Justin Williams | Personal Website</title><subtitle>A personal webpage for displaying information on Justin Williams.</subtitle><author><name>Justin Williams</name></author><entry><title type="html">Query Historical Weather Data with API</title><link href="https://williazo.github.io/data%20science/query-historical-weather-w-api/" rel="alternate" type="text/html" title="Query Historical Weather Data with API" /><published>2021-04-16T00:00:00-07:00</published><updated>2021-04-16T00:00:00-07:00</updated><id>https://williazo.github.io/data%20science/query-historical-weather-w-api</id><content type="html" xml:base="https://williazo.github.io/data%20science/query-historical-weather-w-api/">&lt;p&gt;It has been a while since I last posted a blog to the site here. This has been due to a combination of factors including:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Finishing my dissertation/defense :tada:&lt;/li&gt;
  &lt;li&gt;Starting a new job with the Los Angeles Dodgers :baseball:&lt;/li&gt;
  &lt;li&gt;General lack of motivation to write :pen:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;2020 was an abnormal year for many of us, but things have started to become more normal both personally and in the world around as vaccine rollout here in Los Angeles is now open to all adults 16+. With this return to normalcy, I have found a renewed desire to pick up the virtual pen and continue to write new posts.&lt;/p&gt;

&lt;p&gt;My post today is on how you can use an API to query historical weather data, given a location and date of interest. The API I have found particularly useful for this is the one provided by &lt;a href=&quot;https://www.visualcrossing.com&quot;&gt;Visual Crossing Weather Data&lt;/a&gt;. Users can sign-up through their website to create a free account which comes with a unique API key. This free tier allows you to run 1,000 requests per day. Their service is particularly helpful in that it allows you to query historical dates, which are not available at the free tier for services like OpenWeather API.&lt;/p&gt;

&lt;h2 id=&quot;example&quot;&gt;Example&lt;/h2&gt;

&lt;p&gt;Below is an example showing how to retrieve the weather for Los Angeles, CA on August 9th, 1991 at 10am local time using Python.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;requests&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;base_url&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'https://weather.visualcrossing.com/VisualCrossingWebServices/rest/services/timeline/'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;query_key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'?key='&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;YOUR_API_KEY_HERE&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;query_params&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'&amp;amp;include=current&amp;amp;unitGroup=us'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;query_loc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'Los Angeles, CA'&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;query_date&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'1991-08-09T10:00:00'&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;base_url&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_loc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;'/'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_date&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_key&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;query_params&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;weather_conditions&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;response&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;json&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'currentConditions'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Temp: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;weather_conditions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'temp'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt; Humidity: &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;weather_conditions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;'humidity'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Note that above we set the parameter &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;include=current&lt;/code&gt; so that we return a single record for the current time requested. By default the request will return records for every hour, which can end up using more requests then you need. We also set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;amp;unitGroup=us&lt;/code&gt; to return values in US units, e.g., will return temperature in degrees Fahrenheit. Above we specified the location as {City, State} but it will also handle other partial address forms such as {Street Address, City, State}, US Zip Codes, or Lat/Lon coordinates.&lt;/p&gt;

&lt;p&gt;For more details on the available parameters and query structure see their &lt;a href=&quot;https://www.visualcrossing.com/resources/documentation/weather-api/timeline-weather-api/&quot;&gt;documentation&lt;/a&gt; of the Timeline Weather API, as it is flexible to adapt to many different use cases.&lt;/p&gt;

&lt;p&gt;By using this API, you can reliably and consistently query weather information to include as features in a data analytics projects. Or you can use it to query the weather on your birthday from any location.&lt;/p&gt;</content><author><name>Justin Williams</name></author><category term="data science" /><category term="python" /><category term="weather" /><category term="API" /><summary type="html">It has been a while since I last posted a blog to the site here. This has been due to a combination of factors including:</summary></entry><entry><title type="html">GitHub Welcome Feature</title><link href="https://williazo.github.io/programming/github-welcome/" rel="alternate" type="text/html" title="GitHub Welcome Feature" /><published>2020-07-13T00:00:00-07:00</published><updated>2020-07-13T00:00:00-07:00</updated><id>https://williazo.github.io/programming/github-welcome</id><content type="html" xml:base="https://williazo.github.io/programming/github-welcome/">&lt;p&gt;Today, I wanted to write a brief blog about a new release from GitHub that allows users to create personal welcome messages automatically. This new feature was released as a “secret” feature in a recent GitHub update.&lt;/p&gt;

&lt;h2 id=&quot;unlocking-the-secret&quot;&gt;Unlocking the Secret&lt;/h2&gt;

&lt;p&gt;To create the welcome message you must create a repository with the same name as your GitHub username. For instance my username is williazo, so to unlock this feature I would simply create a new repository with the name williazo. Note that as soon as you give the repository the appropriate name, a note will appear identifying that you have uncovered the secret. Ensure that your repository is set to public and initialize it with a README.md. The README.md serves as the template for creating the welcome message and comes with some initial suggestions for things to includes such as projects you are currently working on, contact info, etc. From there though the choice is yours about what and how you want to include relavent information. Below is a screenshot of the landing page for my GitHub account with the new welcome message.&lt;/p&gt;

&lt;figure&gt;
  
&lt;img src=&quot;/assets/images/posts_images/2020-07-13-github-welcome/jrw_github_welcome.jpg&quot; alt=&quot;justin_welcome&quot; /&gt;

  &lt;figcaption&gt;My personal GitHub landing page.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;You can see that this provides you an opportunity to explain a little bit more about yourself and your goals rather than strictly listing your repositories. You will also notice that the welcome README.md supports GitHub emojis&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;h2 id=&quot;inspiration&quot;&gt;Inspiration&lt;/h2&gt;

&lt;p&gt;To get the creative juices flowing I have also included several examples below of welcome pages to serve as inspiration. Links to each of the respective GitHub pages is included in the captions. There is also a great directory at &lt;a href=&quot;https://github.com/abhisheknaiidu/awesome-github-profile-readme&quot;&gt;https://github.com/abhisheknaiidu/awesome-github-profile-readme&lt;/a&gt; dedicated to showcasing these welcome pages.&lt;/p&gt;

&lt;figure class=&quot;half full&quot;&gt;
  
    
      &lt;img src=&quot;/assets/images/posts_images/2020-07-13-github-welcome/enzo_github_welcome.png&quot; alt=&quot;Enzo GitHub Welcome&quot; /&gt;
    
  
    
      &lt;img src=&quot;/assets/images/posts_images/2020-07-13-github-welcome/vansh_github_welcome.png&quot; alt=&quot;Vansh GitHub Welcome&quot; /&gt;
    
  
  
    &lt;figcaption&gt;Examples of interesting GitHub welcome pages. &lt;br /&gt;
Example 1: Available at &lt;a href=&quot;https://github.com/BLKKKBVSIK&quot;&gt;https://github.com/BLKKKBVSIK&lt;/a&gt; with animation. &lt;br /&gt;
Available at &lt;a href=&quot;https://github.com/vanshkapoor&quot;&gt;https://github.com/vanshkapoor&lt;/a&gt;.
&lt;/figcaption&gt;
  
&lt;/figure&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;For a complete list of the supported emojis see &lt;a href=&quot;https://gist.github.com/rxaviers/7360908&quot;&gt;https://gist.github.com/rxaviers/7360908&lt;/a&gt;. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content><author><name>Justin Williams</name></author><category term="programming" /><category term="github" /><category term="features" /><category term="secret" /><summary type="html">Today, I wanted to write a brief blog about a new release from GitHub that allows users to create personal welcome messages automatically. This new feature was released as a “secret” feature in a recent GitHub update.</summary></entry><entry><title type="html">vscode-Intro for Python</title><link href="https://williazo.github.io/statistics/vscode-intro-for-pyton/" rel="alternate" type="text/html" title="vscode-Intro for Python" /><published>2020-06-18T00:00:00-07:00</published><updated>2020-06-18T00:00:00-07:00</updated><id>https://williazo.github.io/statistics/vscode-intro-for-pyton</id><content type="html" xml:base="https://williazo.github.io/statistics/vscode-intro-for-pyton/">&lt;p&gt;I am back on a roll now with blogging and I can feel the momentum. This week I wanted to spend some time going over an introduction to one of my favorite new discoveres, &lt;a href=&quot;https://code.visualstudio.com&quot;&gt;Visual Studio Code&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Visual Studio Code, referred to as vscode throughout the remaining post, in its most simple sense is a text editor, but it is a text editor on steroids. This software was developed by the Microsoft Team and has become extremely popular within the software develoment community. The basic install version of vscode comes pre-installed with several usefull features such as IntelliSense that provides users with comfortable highlighting and autocomplete, built in Git compatibility for distributed version control, and an expansive catalogue of extensions. These extensions range from highly functional to purely aesthetic.&lt;/p&gt;

&lt;p&gt;My personal favorite aesthetic extension is &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=naumovs.color-highlight&quot;&gt;Color Highligher&lt;/a&gt; that allows you to preview colors entered as Hex, e.g., “#F00123”,  values or rgb, e.g., “rgb(80, 20, 80)”, functions within the editor rather than after running the code. See the screen below from vscode that shows the preview color for each of these cases, red and purple, in the text editor as boxes before the text.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts_images/2020-06-18-vscode/vscode-color-highlighter.png&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;

&lt;p&gt;While it has many of these abilities to help make code more readable and programmer friendly, it become widely accepted among developers due to its performance with languages such as JavaScript, CSS, and other web development essentials. Today, in addition to web development vscode is also gaining increasing popularity among data scientists due to its Pyton compatibility.&lt;/p&gt;

&lt;h2 id=&quot;vscode-python&quot;&gt;vscode-Python&lt;/h2&gt;

&lt;p&gt;We can add the Python extension from the vscode marketplace using their extension &lt;a href=&quot;https://marketplace.visualstudio.com/items?itemName=ms-python.python&quot;&gt;here&lt;/a&gt;. This extension allows you to select which Python interpretor, Python 2 or Python 3, you want to run based on what you have installed locally on your system. One of my favorite things though about working with Python in vscode has been the integration it provides for working with Jupyter notebooks.&lt;/p&gt;

&lt;h3 id=&quot;integration-with-jupyter-notebooks&quot;&gt;Integration with Jupyter Notebooks&lt;/h3&gt;

&lt;p&gt;As someone who was introduced into statistical programming primarily using R, I have struggled everytime I have tried to switch to working in Python because I had become so dependent on the RStudio IDE with windows to display the local environment, generate plots, etc. However, on the occasions when I have worked on projects in Python I have tried to work using Jupyter notebooks.&lt;/p&gt;

&lt;p&gt;Jupyter was developed as a project to allow for interactive computing across different programming languages such as R, Julia, Python, and others. Jupyter notebooks are web applications that allow you to simultanously include live code in your desired language alongside markdown blocks that would allow you to write text and equations. By allowing the code to be live, anyone who was reading the notebook could instantly run the code themselves to check that they were receiving the same output or download the notebook and expand/edit the code easily wihout having to copy and paste. In addition, Jupyter notebooks automatically render&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; within GitHub as you can see from this &lt;a href=&quot;https://github.com/williazo/microbiomeDASim/blob/master/inst/script/mouse_microbiome_approximation.ipynb&quot;&gt;notebook&lt;/a&gt; which I used when writing documentation for my pacakge &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;microbiomeDASim&lt;/code&gt; to simulate longitudinal differential abundance.&lt;/p&gt;

&lt;p&gt;While I enjoyed all of these features about Jupyter notebooks, I still had challenges transitioning to working in them full-time as I found it difficult and clunky to open notebooks from the terminal which seemed to regularly throw error messages whenever I updated Python. I was so grateful to find that once I started using vscode that it natively supported working Jupyter notebooks. For any file with extension .ipynb vscode will automatically open the Jupyter notebook editor. Below I have included a short GIF that shows the vscode interface for Jupyter notebooks. In this GIF I can click a markdown block, enter text, run Python chunks, and even view local variables.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts_images/2020-06-18-vscode/vscode_pynb_ex.gif&quot; alt=&quot;alt text&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The full Jupyter notebook used in the GIF can be downloaded &lt;a href=&quot;/assets/code/2020-06-18-vscode-intro-for-python.ipynb&quot;&gt;here&lt;/a&gt; for those interested in trying to play around with some of the features. Overall, I have enjoyed discovering many of the features within vscode that make programming slighlty easier, especially when working in Python.&lt;/p&gt;

&lt;h2 id=&quot;additional-notes&quot;&gt;Additional Notes&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;There are extensions for working in R with vscode. From my brief experience it works really well for handling R Markdown, i.e., files with .rmd extensions, but lacks many of the qualities that make working in RStudio seamless such as viewing the data environment and plots. I need to spend some more time playing around with writing R code using vscode-R, and I will refrain full judgement until that point. As an alternative, you can also change the language selected in the .ipynb file to support R allowing you to write Jupyter notebooks in R.&lt;/li&gt;
  &lt;li&gt;For sharing Jupyter notebooks it can be helpful to transport the code to the &lt;a href=&quot;https://colab.research.google.com/notebooks/intro.ipynb&quot;&gt;Google Collab&lt;/a&gt; platform as they will allow you to run notebooks and create a simple link for other users to access the code rather than installing Jupyter and its dependencies locally.&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;While the notebooks are rendered they cannot run code live when displayed within a GitHub page as they are not running using the Jupyter server. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content><author><name>Justin Williams</name></author><category term="statistics" /><category term="vscode" /><category term="python" /><category term="notebook" /><category term="Jupyter" /><summary type="html">I am back on a roll now with blogging and I can feel the momentum. This week I wanted to spend some time going over an introduction to one of my favorite new discoveres, Visual Studio Code.</summary></entry><entry><title type="html">Comparing R Graphic Packages - ggplot2 vs. plotly</title><link href="https://williazo.github.io/statistics/plotly-ggplot2/" rel="alternate" type="text/html" title="Comparing R Graphic Packages - ggplot2 vs. plotly" /><published>2020-06-11T00:00:00-07:00</published><updated>2020-06-11T00:00:00-07:00</updated><id>https://williazo.github.io/statistics/plotly-ggplot2</id><content type="html" xml:base="https://williazo.github.io/statistics/plotly-ggplot2/">&lt;p&gt;After starting this blogging section of my personal website I set a lofty goal to try to have a new blog post each week. However, reality set in quickly and this is now my first post in nearly 5 months. Despite having more time available at home due to the COVID-19 quarantine and safer at home mandates in Los Angeles County&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;, I continually found ways to avoid writing new posts.&lt;/p&gt;

&lt;p&gt;That was until today. I recently found myself motivated to write this new post as I have been working with different graphics packages in R as part of my dissertation work. In particular, I wanted to compare two popular R packages for creating graphics: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;motivating-example&quot;&gt;Motivating Example&lt;/h2&gt;

&lt;p&gt;To demonstrate some of the abilities of these two packages I will use my own R package, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rwindow.baseball&lt;/code&gt;, to pull several baseball statistics and create relevant graphics for attendance figures for the Los Angeles Dodgers. I first start by installing the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rwindow.baseball&lt;/code&gt; package.&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# install.packages(&quot;devtools&quot;) #uncomment if devtools has not been installed previously&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;devtools&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;install_github&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;williazo/rwindow.baseball&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now I will pull&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; attendance figures for the Los Angeles Dodgers from the 2015-2019.&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tm_standings_schedule&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;LAD&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start_year&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2015&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;end_year&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2019&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;From this data we may be particularly interested to see attendance patterns over time with respect to the following objectives.&lt;/p&gt;

&lt;h3 id=&quot;objectives&quot;&gt;Objectives&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;Graph home attendance for each Dodger game from 2015-2019&lt;/li&gt;
  &lt;li&gt;Estimate trend lines for each year&lt;/li&gt;
  &lt;li&gt;Identify attendance on July 4th as special date of interest&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In order to achieve these three objectives we will first pre-process our data before passing it off to our respective graphic packages. I use piping features from the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dplyr&lt;/code&gt; package to process the data which is also a component of the tidyverse collection.&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tidyverse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tm_standings_schedule&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;LAD&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;start_year&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2015&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;end_year&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2019&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home_gm&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;#only including home games&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group_by&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mutate&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home_gm_num&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row_number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ungroup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;july_forth&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ifelse&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;grepl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Jul 4&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Our data is now ready to be used to generate our graphics of interest.&lt;/p&gt;

&lt;h2 id=&quot;ggplot2&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;This is the most common graphics package outside of base R graphics. It is the result of the work of one of the most well-known contributors to R, Hadley Wickham, and a key component of the increasingly popular tidyverse collection. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt; has made it incredibly easy and flexible for users to create high quality graphics using a consistent syntax. For a gentle introduction to some of the features and capabilities of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt; I would point users to Chapter 3 of Hadley’s “R for Data Science” book available for free at &lt;a href=&quot;https://r4ds.had.co.nz/data-visualisation.html&quot;&gt;https://r4ds.had.co.nz/data-visualisation.html&lt;/a&gt; that outlines the grammar of graphics as envisioned by its creator.&lt;/p&gt;

&lt;p&gt;We achieve our objectives using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt; using the following code&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggplot2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ggplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home_gm_num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Attendance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;group&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Tm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_point&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;facet_wrap&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xlab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Home Game #&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scale_x_continuous&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;breaks&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;seq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;81&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ylab&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Total Attendance&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;stat_smooth&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;method&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;loess&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;se&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;FALSE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;black&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;linetype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;scale_color_manual&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Team&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;values&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#005A9C&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;geom_vline&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;july_forth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;aes&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xintercept&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home_gm_num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;col&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;red&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;linetype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;theme_bw&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;guides&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;FALSE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts_images/2020-06-11-plotly-ggplot2/attnd_update.png&quot; alt=&quot;attn_ggplot2&quot; /&gt;&lt;/p&gt;

&lt;p&gt;From this graph we can see that the home attendance has been consistently been high over the past 5 years. There was also a notable increase in fans during later games in the 2017 season and high variability in the beginning of the season. We also see that the Dodgers have had a home July 4th game each season. During these games 2016 was the only case where attendance was relatively low while all other years attendance on July 4th was near the maximum.&lt;/p&gt;

&lt;h2 id=&quot;plotly&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt;&lt;/h2&gt;

&lt;p&gt;As someone who has used R frequently for academic research and professional internships, I have defaulted to using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt; almost religiously when generating graphics. It wasn’t until the beginning of this year when I was looking for options to create 3d visualizations in R that I stumbled upon &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt;. The developers at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; have written this code for several different software systems including Python, R, and JavaScript. My go-to resource as I have started learning about &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; has been their R reference materials available at &lt;a href=&quot;https://plotly.com/r/&quot;&gt;https://plotly.com/r/&lt;/a&gt; which contains examples and documentation to help guide beginners.&lt;/p&gt;

&lt;p&gt;To compare the graphic packages, I will attempt to achieve the same objectives as described in the Motivating Example using the processed data. First, we need to generate the smoothed LOESS estimates manually for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; as it does not have an analogous &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stat_smooth()&lt;/code&gt; built-in function.&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plotly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attnd_loess&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Attendance&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home_gm_num&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt_loess&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;-&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data.frame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;home_gm_num&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Year&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Tm&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)],&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                           &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;pred_attnd&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attnd_loess_pred&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We then graph the results using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; syntax as follows&lt;/p&gt;

&lt;div class=&quot;language-r highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;plot_ly&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home_gm_num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Attendance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
             &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;linetype&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
             &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'lines+markers'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'scatter'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
             &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hovertemplate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;paste&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;i&amp;gt;Home Game #&amp;lt;/i&amp;gt;: %{x}'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                            &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;br&amp;gt;&amp;lt;i&amp;gt;Attendance&amp;lt;/i&amp;gt;: %{y:,.0f}'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                            &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;br&amp;gt;Date:'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                            &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;br&amp;gt;Current Streak'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Streak&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_lines&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home_gm_num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;attnd_loess&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'LOESS'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hovertemplate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;paste&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;i&amp;gt;Home Game #&amp;lt;/i&amp;gt;: %{x}'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                                &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;br&amp;gt;&amp;lt;i&amp;gt;Smoothed Attendance&amp;lt;/i&amp;gt;: %{y:,.0f}'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                                &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;br&amp;gt;Date:'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                                &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;br&amp;gt;Current Streak'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Streak&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;add_trace&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;subset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;lad_dt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;july_forth&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;home_gm_num&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Attendance&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;mode&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;markers&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;scatter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;July 4th&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;marker&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'rgba(16, 78, 139, 1)'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                        &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'rgba(16, 78, 139, .8)'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
            &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;hovertemplate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=~&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;paste&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;i&amp;gt;Home Game #&amp;lt;/i&amp;gt;: %{x}'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                                 &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;br&amp;gt;&amp;lt;i&amp;gt;Attendance&amp;lt;/i&amp;gt;: %{y:,.0f}'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                                 &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;br&amp;gt;Year:'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Year&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
                                 &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'&amp;lt;br&amp;gt;Current Streak'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Streak&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;%&amp;gt;%&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;layout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;xaxis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Home Game #'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dtick&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;tick0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
         &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;yaxis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'Attendance'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;iframe src=&quot;/assets/images/posts_images/2020-06-11-plotly-ggplot2/plotly_attnd.html&quot; width=&quot;800&quot; height=&quot;500&quot; scrolling=&quot;yes&quot; seamless=&quot;seamless&quot; frameborder=&quot;0&quot;&gt; &lt;/iframe&gt;

&lt;p&gt;We now have an .html figure showing the same attendance figures as we graphed in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt;. Initially this graphic appears more dense with all features and years displayed simultaneously. However, we can click, or double-click, on a specific year, LOESS trend, and July 4th point to systematically look at trends of interest. Alternatively, we can examine only LOESS curves or only July 4th attendance figures. This figure also allows users to manually edit the “hovertemplate” to control the text that is displayed as you move over points or trend lines. This feature allows us to add additional information such as Date and Current Streak to motivate additional exploration of the attendance figures.&lt;/p&gt;

&lt;h2 id=&quot;key-differences&quot;&gt;Key Differences&lt;/h2&gt;

&lt;p&gt;Having used both packages to generate graphics that achieve our objective, below I have included a table highlighting some of the key differences between these two graphic packages in R.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt; &lt;/th&gt;
      &lt;th&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt;&lt;/th&gt;
      &lt;th&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt;&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;Filetype&lt;/td&gt;
      &lt;td&gt;.jpeg, .pdf, .png, etc.&lt;/td&gt;
      &lt;td&gt;.html&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Interactive?&lt;/td&gt;
      &lt;td&gt;No&lt;/td&gt;
      &lt;td&gt;Yes&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;R Documentation&lt;/td&gt;
      &lt;td&gt;+++&lt;/td&gt;
      &lt;td&gt;+&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Extensions&lt;/td&gt;
      &lt;td&gt;Extensive&lt;/td&gt;
      &lt;td&gt;Limited&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Software Availability&lt;/td&gt;
      &lt;td&gt;R&lt;/td&gt;
      &lt;td&gt;R, Python, JavaScript&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Sharing&lt;/td&gt;
      &lt;td&gt;Globally&lt;/td&gt;
      &lt;td&gt;Locally&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;The main difference between graphics constructed using these packages within R is the corresponding filetype. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt; creates static images with the extension of choice while &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; creates dynamic .html images which are web responsive. This difference allows for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; to have interactive figures.&lt;/p&gt;

&lt;p&gt;Another key difference is the available documentation. As &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt; has been developed for over 10 years it has an extremely large amount of documentation and help available when searching online, while &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; has more limited documentation as it has been gaining popularity in the R community more recently.&lt;/p&gt;

&lt;p&gt;Further, in the example above we saw how simple extensions that are built into the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt; framework can easily be incorporated into our figures. Adding trends lines was a simple addition of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;stat_smooth()&lt;/code&gt; function while points had to be manually estimated in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;As mentioned earlier the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; package is available natively in multiple software languages including R, Python, and JavaScript, which can be especially helpful when moving between these languages.&lt;/p&gt;

&lt;p&gt;Finally, sharing figures generated from these two packages is significantly different as static images created by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt; are easily shared globally while .html files produced by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; are available only locally by default.&lt;/p&gt;

&lt;h2 id=&quot;recommendation&quot;&gt;Recommendation&lt;/h2&gt;

&lt;p&gt;In conclusion to this post, I would like to give users my two-cents about which package to choose when debating how to create R graphics. My default is to still to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ggplot2&lt;/code&gt; as the static figures they create are easy to save and pass along to colleagues, incorporate into reports, and can be read uniformly. However, when the goal is to present 3d graphics or materials that allow the user to investigate within the graphic manually then I reach for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt;. An area where I tend to explore more between these graphics packages is generating spatial figures as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; seems to offer more many more options for creating these maps as shown in &lt;a href=&quot;https://plotly.com/r/#maps&quot;&gt;https://plotly.com/r/#maps&lt;/a&gt;. For researchers working across multiple software systems, such as Python and R, I would also suggest focusing efforts on &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; as this will allow for consistency when moving between languages.&lt;/p&gt;

&lt;p&gt;For those interested, the complete R code used to generate the images and data is downloadable &lt;a href=&quot;/assets/code/2020-06-11-plotly-ggplot.R&quot;&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;For those interested the following is a link to the state of California COVID-19 dashboard to track cases &lt;a href=&quot;https://covid19.ca.gov/data-and-tools/&quot;&gt;here&lt;/a&gt;. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Note that this data is pulled from &lt;a href=&quot;https://www.baseball-reference.com&quot;&gt;baseball-reference.com&lt;/a&gt; team home pages. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Since &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;plotly&lt;/code&gt; creates .html files these can be included in local presentations only by default but can be hosted on web otherwise to share globally, e.g., on GitHub repository. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content><author><name>Justin Williams</name></author><category term="statistics" /><category term="ggplot2" /><category term="plotly" /><category term="data viz" /><summary type="html">After starting this blogging section of my personal website I set a lofty goal to try to have a new blog post each week. However, reality set in quickly and this is now my first post in nearly 5 months. Despite having more time available at home due to the COVID-19 quarantine and safer at home mandates in Los Angeles County1, I continually found ways to avoid writing new posts. For those interested the following is a link to the state of California COVID-19 dashboard to track cases here. &amp;#8617;</summary></entry><entry><title type="html">From the Gym, to the Crag, to the Ground</title><link href="https://williazo.github.io/climbing/gym-crag-ground/" rel="alternate" type="text/html" title="From the Gym, to the Crag, to the Ground" /><published>2020-01-22T00:00:00-08:00</published><updated>2020-01-22T00:00:00-08:00</updated><id>https://williazo.github.io/climbing/gym-crag-ground</id><content type="html" xml:base="https://williazo.github.io/climbing/gym-crag-ground/">&lt;p&gt;It might have taken slightly longer than a week, but I am here to officially kick off this blogging adventure. After my bold proclamation in last weeks welcoming post to try and write these once a week, I have to admit that I went into a slight panic. Immediately I regretted having uttered this statement, let alone placing it online where the evidence is eternal. I thought about removing it and scrapping this whole idea. What sort of topics would I feel passionate about enough to warrant long form discussion? How would I be able to present things in a compelling manner?&lt;/p&gt;

&lt;p&gt;But despite this self-doubt I decided to stick to my gut, and hoped that magically an idea would fall into my lap. As chance would have it, such an idea did indeed fall into my lap, or more accurately I found the idea while lying on the ground staring up at rocks.&lt;/p&gt;

&lt;figure&gt;
  
&lt;img src=&quot;/assets/images/posts_images/2020-01-22-gym-crag-ground/looking_up.jpg&quot; alt=&quot;Looking Up&quot; /&gt;

  &lt;figcaption&gt;Looking up at Pixie Boulder in Joshua Tree National Park (JTNP).&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;One of my hobbies is rock climbing, specifically bouldering. My passion for climbing has waxed and waned depending on my time availability, climbing partners, and general motivation. Recently, I have become reinvigorated to spend more time practicing climbing.&lt;/p&gt;

&lt;p&gt;I have only ever climbed in indoor gyms, and had always been curious to try and take these skills outdoors. However, whenever I thought about this idea I became anxious that I would make a fool of myself in front of other more experienced climbers. I have never been a particularly strong climber, maxing out at V3&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; boulders indoors at &lt;a href=&quot;https://touchstoneclimbing.com/hollywood-boulders/&quot;&gt;Hollywood Boulders&lt;/a&gt;, so I knew that I would have limited options in terms of boulders within my abilities outdoors. Luckily though, living in Los Angeles we have easy access to a mecca for rock climbing, Joshua Tree National Park. So this last week we packed up the car with climbing shoes, crash pad, and an optimistic outlook to try and tackle my first outdoor bouldering session.&lt;/p&gt;

&lt;h1 id=&quot;joshua-tree-day-1&quot;&gt;Joshua Tree: Day 1&lt;/h1&gt;
&lt;p&gt;When we arrived in Joshua Tree we had to stop by &lt;a href=&quot;http://www.nomadventures.com&quot;&gt;Nomad Adventures&lt;/a&gt; to pick up some last minute necessities for climbing and camping. They were super friendly and helpful as we were shopping around, even providing a list of their recommended boulders to check out while we were in the park. In particular they mentioned an area of the park called Barker Dam, which had some of the most classic boulders including &lt;em&gt;Gunsmoke&lt;/em&gt;. This area is also usually less crowded then some of the other nearby climbing locations such as Hidden Valley.&lt;/p&gt;

&lt;h2 id=&quot;barker-dam&quot;&gt;Barker Dam&lt;/h2&gt;
&lt;p&gt;With this suggestion we made it over to Barker Dam, and after a short approach hike I was able to officially try my first outdoor boulder, &lt;em&gt;Gunsmoke&lt;/em&gt;. This is a V3 boulder, which is the level I am used to climbing indoors at the gym, and the employee at Nomad Adventures also mentioned that it was an easier V3 with most of the difficulty coming from the length of the boulder. There were a few other climbers working the &lt;em&gt;Gunsmoke&lt;/em&gt; boulder when we arrived bringing out all of my original anxieties about failing in front of these strangers. I eventually hopped on the boulder and immediately found out that outdoor bouldering really was harder than the gym. Connecting even two moves felt like a Herculean effort, and this problem spanned over 100 feet!&lt;/p&gt;

&lt;p&gt;After falling a couple of times I began to strike up a conversation with the other climber working the problem. We began to exchange beta&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;, which was extremely helpful for me to gain someone else’s perspective on how to tackle this problem. It also assuaged some of my biggest concerns about bouldering outdoors with other climbers. I felt so much more comfortable failing without worrying about being judged.&lt;/p&gt;

&lt;p&gt;I continued to work on &lt;em&gt;Gunsmoke&lt;/em&gt; for a little while longer making incremental improvements with each attempt. We then moved over to another boulder in the Barker Dam area called &lt;em&gt;The Chube&lt;/em&gt;, which was graded as a V2. Again, all of the moves on this problem felt incredibly hard but it was exciting nonetheless to work on it. After several unsuccessful attempts with many quizzical looks at the rock trying to find any semblance of a foothold, we eventually decided to call it a day and explore the rest of the park.&lt;/p&gt;

&lt;p&gt;Although the first day of climbing did not result in any successful attempts, I left feeling proud that I was able to conquer the fear of failure. I also realized that the next day I would need to lower my sights and try working on problems that were much easier.&lt;/p&gt;

&lt;figure class=&quot;half full&quot;&gt;
  
    
      &lt;img src=&quot;/assets/images/posts_images/2020-01-22-gym-crag-ground/boulder_approach.jpg&quot; alt=&quot;Barker Dam Approach Route&quot; /&gt;
    
  
    
      &lt;img src=&quot;/assets/images/posts_images/2020-01-22-gym-crag-ground/moving_on_gunsmoke.jpg&quot; alt=&quot;Gunsmoke Movements&quot; /&gt;
    
  
    
      &lt;img src=&quot;/assets/images/posts_images/2020-01-22-gym-crag-ground/the_chube_staredown.jpg&quot; alt=&quot;The Chube Stare Down&quot; /&gt;
    
  
    
      &lt;img src=&quot;/assets/images/posts_images/2020-01-22-gym-crag-ground/chalking_up.jpg&quot; alt=&quot;Chalking Up for the Climb&quot; /&gt;
    
  
  
    &lt;figcaption&gt;Snapshot of the 1st day of bouldering in Barker Dam at JTNP.
&lt;/figcaption&gt;
  
&lt;/figure&gt;

&lt;h1 id=&quot;joshua-tree-day-2&quot;&gt;Joshua Tree: Day 2&lt;/h1&gt;
&lt;p&gt;We spent the night under the stars at the Indian Cove Campground which was truly an amazing experience, despite the chilly nighttime temperatures. After deciding to grab breakfast in town rather than making a sketchy Huevos Rancheros backpacking meal, we were once again back in the park looking to find a problem that I could finish. Browsing through a climbing app on my phone during breakfast I found an interesting problem that was one of the easiest grades and seemed like the best option for success. So we headed into the park to the Planet X area which had the problem that had caught my eye, &lt;em&gt;Dragon Skin&lt;/em&gt;.&lt;/p&gt;

&lt;h2 id=&quot;planet-x&quot;&gt;Planet X&lt;/h2&gt;
&lt;p&gt;Finding the Planet X boulders was slightly more challenging as there was no dedicated parking lot, but rather a paved pullout with room for about 3 cars. Since we had arrived directly after breakfast there was still parking available, and only one other group that was just unpacking there gear as we arrived. There are many boulders in this area and as we walked down the trail I assumed that we would end up at a different boulder than the other group, but to my surprise we both ended up starting on the exact same problem.&lt;/p&gt;

&lt;p&gt;I could clearly tell that this group was more experienced as they made easy work of the Dragon Skin problem. Their warm-up problem would be my main problem, but I was happy to watch them complete it and know where each of the moves were supposed to be. After they had all dismounted, which ended up being a harder process with this boulder as the back side was difficult to descend, I walked up to the start holds and began to make my way up.&lt;/p&gt;

&lt;figure class=&quot;third full&quot;&gt;
  
    
      &lt;img src=&quot;/assets/images/posts_images/2020-01-22-gym-crag-ground/dragon_skin_contemplation.jpg&quot; alt=&quot;Dragon Skin Contemplation&quot; /&gt;
    
  
    
      &lt;img src=&quot;/assets/images/posts_images/2020-01-22-gym-crag-ground/dragon_skin_climb.jpg&quot; alt=&quot;Dragon Skin Climb&quot; /&gt;
    
  
    
      &lt;img src=&quot;/assets/images/posts_images/2020-01-22-gym-crag-ground/dragon_skin_top.jpg&quot; alt=&quot;Dragon Skin View from the Top&quot; /&gt;
    
  
  
    &lt;figcaption&gt;Climbing Dragon Skin at Planet X in JTNP.
&lt;/figcaption&gt;
  
&lt;/figure&gt;

&lt;p&gt;I made it! Standing at the top of the boulder I was so happy! I had finally done my first outdoor boulder! It was an amazing feeling and one that I would not soon forget.&lt;/p&gt;

&lt;p&gt;I tried another problem to the side of the Dragon Skin problem, only to be shut down immediately in a repeat of the experience at Barker Dam the previous day. But this failure rolled off my back and I basked in my earlier success.&lt;/p&gt;

&lt;p&gt;We spent the rest of the day enjoying some of the other hikes and sights around Joshua Tree before heading back to LA.&lt;/p&gt;

&lt;h1 id=&quot;final-thoughts&quot;&gt;Final Thoughts&lt;/h1&gt;
&lt;p&gt;Although my first time climbing outdoors was a humbling experience, it gave me motivation to continue to work hard and come back to top out these boulders. I am excited to improve and return to finish some of these boulders that felt impossible during this first session.&lt;/p&gt;

&lt;figure&gt;
  
&lt;img src=&quot;/assets/images/posts_images/2020-01-22-gym-crag-ground/the_chube_project.jpg&quot; alt=&quot;Chube Project&quot; /&gt;

  &lt;figcaption&gt;The Chube, V2, Barker Dam, JTNP.&lt;/figcaption&gt;
&lt;/figure&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Boulders are rated on the V-scale in the United States which generally ranges from VB to V15 with higher values corresponding to more difficult problems. For a full description of the grading system see the following page from 99Boulders: &lt;a href=&quot;https://www.99boulders.com/bouldering-grades&quot;&gt;https://www.99boulders.com/bouldering-grades&lt;/a&gt;. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Beta is a term used by climbers to describe the moves/steps needed to complete the boulder problem. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;</content><author><name>Justin Williams</name></author><category term="Climbing" /><category term="joshua tree" /><category term="bouldering" /><category term="national park" /><category term="camping" /><category term="travel" /><summary type="html">It might have taken slightly longer than a week, but I am here to officially kick off this blogging adventure. After my bold proclamation in last weeks welcoming post to try and write these once a week, I have to admit that I went into a slight panic. Immediately I regretted having uttered this statement, let alone placing it online where the evidence is eternal. I thought about removing it and scrapping this whole idea. What sort of topics would I feel passionate about enough to warrant long form discussion? How would I be able to present things in a compelling manner?</summary></entry><entry><title type="html">Blogging?…Blogging!</title><link href="https://williazo.github.io/miscellaneous/welcome-blog/" rel="alternate" type="text/html" title="Blogging?…Blogging!" /><published>2020-01-14T00:00:00-08:00</published><updated>2020-01-14T00:00:00-08:00</updated><id>https://williazo.github.io/miscellaneous/welcome-blog</id><content type="html" xml:base="https://williazo.github.io/miscellaneous/welcome-blog/">&lt;p&gt;Hello! Thank you for visiting my website. As I began to explore the structure available, and learned more about how to actually format my material using &lt;a href=&quot;https://jekyllrb.com&quot;&gt;Jekyll&lt;/a&gt;, I have toyed with the idea of starting a blog aspect as part of this content. This would be a collection of posts for my thoughts on stats, sports, life experiences, traveling, cooking, and who knows what else.&lt;/p&gt;

&lt;p&gt;As any great idea starts there is much promise at the beginning and yet much unknown about execution. In this first month or so I will try to post weekly and then we will see where it goes from there. So buckle in for the journey and let’s see where this journey takes me.&lt;/p&gt;</content><author><name>Justin Williams</name></author><category term="Miscellaneous" /><category term="introduction" /><category term="welcome" /><category term="general" /><summary type="html">Hello! Thank you for visiting my website. As I began to explore the structure available, and learned more about how to actually format my material using Jekyll, I have toyed with the idea of starting a blog aspect as part of this content. This would be a collection of posts for my thoughts on stats, sports, life experiences, traveling, cooking, and who knows what else.</summary></entry></feed>