<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/visualizing-the-best/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://www.maxhumber.com/2017/01/21/THE-BEST.html"> max humber</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>How do you measure “The Best”?</p>
<p>It’s not immediately clear. Because, “The Best” is incredibly vague and subjective. My “Best” is not the same as your “Best”. And our “Best”s can converge and diverge depending on what we are measuring and how we measure it.</p>
<p>I think “The Best” is often the wrong question. Usually when we’re looking for “The Best” (are you sick of me saying “The Best” yet?) we’re really just trying to find “The Better”.</p>
<p>Answers to questions like “Who is the best player in the NBA?” or “What is the best city in the world?” or “Which Pokemon is the best?” are fraught with caveats and asterisks and clarifications. And they have to be! What do you mean “Best”? Best Shooter? Best of All Time? Best Last Year? Best in terms of Quality of Living? Best on measures of Entertainment? Best Speeds? Best Attacks? Best Best Best Best Best! Aggh!</p>
<p>To answer these “Best” questions we have to narrow down the problem and convert them into “Better” questions. By slimming down the pool of possible options we can actually start to make some progress!</p>
<ul>
<li>“Who is the better basketball player: Steph Curry, Kawhi Leonard, or Larry Bird?”</li>
<li>“Which city is better: Toronto, London, or San Francisco?”</li>
<li>“Which starter Pokemon (from Gen 1) is better for my team?”</li>
</ul>
<p>These are questions, I think, we can actually answer! But only if we’re explicit about the measures we’re using in our calculations and the weights that we assign to them.</p>
<p>For instance, if we want to find the better basketball player we could come up with some formula that includes assists, shooting, usage, defense, and rebounds. Maybe my formula is <code>y = 2 * Shooting + 1.2 * Usage - 3 * Defense + 1.1 * Assists^2 + 1.3 * Rebounds</code>. But I think reducing five incredibly rich measurements down to one value is absurd. It’s lossy compression! And you might not agree with my formula. You could have a better one. You might really value rebounds. Or you might want to replace usage with steals! Blah Blah Blah Blah Blah.</p>
<p>Worry not! We’ve finally reached the part where I present a method for finding “The Best” (or “The Better”, at least). A visulization for “The Best”. It is inspired by (more like entirely ripped off from) <a target="_blank" rel="nofollow" href="https://fivethirtyeight.com/features/kawhi-leonard-is-the-most-well-rounded-elite-shooter-since-larry-bird/">this</a> FiveThirtyEight article.</p>
<p>All that is required is the <code>tidyverse</code> and <code>forcats</code></p>
<h1>Basketball</h1>
<p>Step 1: Spin up the data</p>
<div>
<pre><code><span>df</span><span> </span><span>&lt;-</span><span> </span><span>tribble</span><span>(</span><span>
</span><span>~</span><span>player</span><span>,</span><span> </span><span>~</span><span>assists</span><span>,</span><span> </span><span>~</span><span>shooting</span><span>,</span><span> </span><span>~</span><span>usage</span><span>,</span><span> </span><span>~</span><span>defense</span><span>,</span><span> </span><span>~</span><span>rebounds</span><span>,</span><span>
</span><span>&quot;Larry Bird&quot;</span><span>,</span><span> </span><span>88</span><span>,</span><span> </span><span>89</span><span>,</span><span> </span><span>93</span><span>,</span><span> </span><span>92</span><span>,</span><span> </span><span>87</span><span>,</span><span>
</span><span>&quot;Kawhi Leonard&quot;</span><span>,</span><span> </span><span>71</span><span>,</span><span> </span><span>94</span><span>,</span><span> </span><span>92</span><span>,</span><span> </span><span>93</span><span>,</span><span> </span><span>62</span><span>,</span><span>
</span><span>&quot;Stephen Curry&quot;</span><span>,</span><span> </span><span>95</span><span>,</span><span> </span><span>92</span><span>,</span><span> </span><span>87</span><span>,</span><span> </span><span>43</span><span>,</span><span> </span><span>32</span><span>,</span><span>
</span><span>&quot;Average&quot;</span><span>,</span><span> </span><span>72</span><span>,</span><span> </span><span>85</span><span>,</span><span> </span><span>32</span><span>,</span><span> </span><span>34</span><span>,</span><span> </span><span>30</span><span>)</span><span> </span><span>%>%</span><span> </span><span>gather</span><span>(</span><span>stat</span><span>,</span><span> </span><span>percentile</span><span>,</span><span> </span><span>-</span><span>player</span><span>)</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>outof4</span><span> </span><span>=</span><span> </span><span>percentile</span><span> </span><span>%/%</span><span> </span><span>25</span><span> </span><span>+</span><span> </span><span>1</span><span>)</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>col</span><span> </span><span>=</span><span> </span><span>ifelse</span><span>(</span><span>player</span><span> </span><span>==</span><span> </span><span>&quot;Average&quot;</span><span>,</span><span> </span><span>&quot;A&quot;</span><span>,</span><span> </span><span>&quot;B&quot;</span><span>))</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>order</span><span> </span><span>=</span><span> </span><span>recode</span><span>(</span><span>stat</span><span>,</span><span> </span><span>assists</span><span> </span><span>=</span><span> </span><span>5</span><span>,</span><span> </span><span>shooting</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>usage</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>defense</span><span> </span><span>=</span><span> </span><span>3</span><span>,</span><span> </span><span>rebounds</span><span> </span><span>=</span><span> </span><span>4</span><span>))</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>stat</span><span> </span><span>=</span><span> </span><span>recode</span><span>(</span><span>stat</span><span>,</span><span> </span><span>assists</span><span> </span><span>=</span><span> </span><span>&quot;ASSIST\nRATE&quot;</span><span>,</span><span> </span><span>shooting</span><span> </span><span>=</span><span> </span><span>&quot;TRUE\nSHOOTING&quot;</span><span>,</span><span> </span><span>usage</span><span> </span><span>=</span><span> </span><span>&quot;USAGE\nRATE&quot;</span><span>,</span><span> </span><span>defense</span><span> </span><span>=</span><span> </span><span>&quot;DEFENSIVE\nBPM&quot;</span><span>,</span><span> </span><span>rebounds</span><span> </span><span>=</span><span> </span><span>&quot;REBOUND\nRATE&quot;</span><span>))</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>stat</span><span> </span><span>=</span><span> </span><span>factor</span><span>(</span><span>stat</span><span>))</span><span>
</span></code></pre>
</div>
<p></p>
<p>Step 2: Graph!</p>
<div>
<pre><code><span>df</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>fct_reorder</span><span>(</span><span>stat</span><span>,</span><span> </span><span>order</span><span>),</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>outof4</span><span>))</span><span> </span><span>+</span><span> </span><span>geom_col</span><span>(</span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.5</span><span>,</span><span> </span><span>aes</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>col</span><span>),</span><span> </span><span>width</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>show.legend</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;white&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_hline</span><span>(</span><span>yintercept</span><span> </span><span>=</span><span> </span><span>seq</span><span>(</span><span>0</span><span>,</span><span> </span><span>4</span><span>,</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>1</span><span>),</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;#949494&quot;</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>0.5</span><span>,</span><span> </span><span>lty</span><span> </span><span>=</span><span> </span><span>3</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_vline</span><span>(</span><span>xintercept</span><span> </span><span>=</span><span> </span><span>seq</span><span>(</span><span>0.5</span><span>,</span><span> </span><span>5.5</span><span>,</span><span> </span><span>1</span><span>),</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;#949494&quot;</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>0.4</span><span>,</span><span> </span><span>lty</span><span> </span><span>=</span><span> </span><span>1</span><span>)</span><span> </span><span>+</span><span>
</span><span>facet_wrap</span><span>(</span><span>~</span><span>player</span><span>)</span><span> </span><span>+</span><span>
</span><span>coord_polar</span><span>()</span><span> </span><span>+</span><span> </span><span>scale_fill_manual</span><span>(</span><span>values</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;#e4e4e4&quot;</span><span>,</span><span> </span><span>&quot;#00a9e0&quot;</span><span>))</span><span> </span><span>+</span><span> </span><span>scale_y_continuous</span><span>(</span><span>
</span><span>limits</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>0</span><span>,</span><span> </span><span>4</span><span>),</span><span> </span><span>breaks</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>2</span><span>,</span><span> </span><span>3</span><span>,</span><span> </span><span>4</span><span>))</span><span> </span><span>+</span><span> </span><span>labs</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>)</span><span> </span><span>+</span><span> </span><span>theme</span><span>(</span><span>
</span><span>panel.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;#FFFFFF&quot;</span><span>),</span><span>
</span><span>plot.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;#FFFFFF&quot;</span><span>),</span><span>
</span><span>strip.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;#FFFFFF&quot;</span><span>),</span><span>
</span><span>strip.text</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>10</span><span>),</span><span>
</span><span>panel.grid</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.ticks</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.text.y</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.text.x</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>7</span><span>),</span><span>
</span><span>panel.spacing</span><span> </span><span>=</span><span> </span><span>grid</span><span>::</span><span>unit</span><span>(</span><span>2</span><span>,</span><span> </span><span>&quot;lines&quot;</span><span>))</span><span>
</span></code></pre>
</div>
<p><img alt="center" src="https://i2.wp.com/www.maxhumber.com/assets/img/the_best_1.png?w=456" data-recalc-dims="1"></p>
<p>I’m not sure what to call this new type of visualization, but I love it! I love it because you can immediately see that Larry Bird is “The Best” basketball player, at least when benchmarked against Steph and Kawhi. And I love it because it’s not just exotic fluff. The bubbles actually help with the interpretation of the data. The bubbles are simply better than columns, in this instance.</p>
<p>Just compare… These two graphs literally contain the same data:</p>
<div>
<pre><code><span>df</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>stat</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>percentile</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>player</span><span>))</span><span> </span><span>+</span><span> </span><span>geom_col</span><span>(</span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.5</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;white&quot;</span><span>)</span><span>
</span></code></pre>
</div>
<p><img alt="center" src="https://i0.wp.com/www.maxhumber.com/assets/img/the_best_2.png?w=456" data-recalc-dims="1"></p>
<div>
<pre><code><span>df</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>stat</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>percentile</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>player</span><span>))</span><span> </span><span>+</span><span> </span><span>geom_col</span><span>(</span><span>alpha</span><span> </span><span>=</span><span> </span><span>0.5</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;white&quot;</span><span>,</span><span>
</span><span>position</span><span> </span><span>=</span><span> </span><span>position_dodge</span><span>())</span><span>
</span></code></pre>
</div>
<p><img alt="center" src="https://i2.wp.com/www.maxhumber.com/assets/img/the_best_3.png?w=456" data-recalc-dims="1"></p>
<p>Like, I can sort of tell that all the blue bars are really tall, but I can’t see much beyond that. It’s hard to jump back and forth between the stats and the players and tease out patterns.</p>
<h1>Pokemon</h1>
<p>Moving to the Pokemon question we can grab data from <a target="_blank" rel="nofollow" href="http://pokemondb.net/">http://pokemondb.net/</a></p>
<div>
<pre><code><span>df</span><span> </span><span>&lt;-</span><span> </span><span>tribble</span><span>(</span><span>
</span><span>~</span><span>Pokemon</span><span>,</span><span> </span><span>~</span><span>HP</span><span>,</span><span> </span><span>~</span><span>Attack</span><span>,</span><span> </span><span>~</span><span>Defense</span><span>,</span><span> </span><span>~</span><span>SpAtt</span><span>,</span><span> </span><span>~</span><span>SpDef</span><span>,</span><span> </span><span>~</span><span>Speed</span><span>,</span><span>
</span><span>&quot;Charizard&quot;</span><span>,</span><span> </span><span>78</span><span>,</span><span> </span><span>84</span><span>,</span><span> </span><span>78</span><span>,</span><span> </span><span>109</span><span>,</span><span> </span><span>85</span><span>,</span><span> </span><span>100</span><span>,</span><span>
</span><span>&quot;Blastoise&quot;</span><span>,</span><span> </span><span>79</span><span>,</span><span> </span><span>83</span><span>,</span><span> </span><span>100</span><span>,</span><span> </span><span>85</span><span>,</span><span> </span><span>105</span><span>,</span><span> </span><span>78</span><span>,</span><span>
</span><span>&quot;Venusaur&quot;</span><span>,</span><span> </span><span>80</span><span>,</span><span> </span><span>82</span><span>,</span><span> </span><span>83</span><span>,</span><span> </span><span>100</span><span>,</span><span> </span><span>100</span><span>,</span><span> </span><span>80</span><span>)</span><span> </span><span>%>%</span><span> </span><span>gather</span><span>(</span><span>stat</span><span>,</span><span> </span><span>value</span><span>,</span><span> </span><span>-</span><span>Pokemon</span><span>)</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>outof6</span><span> </span><span>=</span><span> </span><span>value</span><span> </span><span>%/%</span><span> </span><span>20</span><span> </span><span>+</span><span> </span><span>1</span><span>)</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>order</span><span> </span><span>=</span><span> </span><span>recode</span><span>(</span><span>stat</span><span>,</span><span> </span><span>HP</span><span> </span><span>=</span><span> </span><span>6</span><span>,</span><span> </span><span>Attack</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>SpAtt</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>Defense</span><span> </span><span>=</span><span> </span><span>3</span><span>,</span><span> </span><span>SpDef</span><span> </span><span>=</span><span> </span><span>4</span><span>,</span><span> </span><span>Speed</span><span> </span><span>=</span><span> </span><span>5</span><span>))</span><span>
</span></code></pre>
</div>
<p></p>
<p>Display it in the same way:</p>
<div>
<pre><code><span>df</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>fct_reorder</span><span>(</span><span>stat</span><span>,</span><span> </span><span>order</span><span>),</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>outof6</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>Pokemon</span><span>))</span><span> </span><span>+</span><span> </span><span>geom_col</span><span>(</span><span>alpha</span><span> </span><span>=</span><span> </span><span>3</span><span>/</span><span>4</span><span>,</span><span> </span><span>width</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>show.legend</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;white&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_hline</span><span>(</span><span>yintercept</span><span> </span><span>=</span><span> </span><span>seq</span><span>(</span><span>0</span><span>,</span><span> </span><span>6</span><span>,</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>1</span><span>),</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;#949494&quot;</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>0.5</span><span>,</span><span> </span><span>lty</span><span> </span><span>=</span><span> </span><span>3</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_vline</span><span>(</span><span>xintercept</span><span> </span><span>=</span><span> </span><span>seq</span><span>(</span><span>0.5</span><span>,</span><span> </span><span>5.5</span><span>,</span><span> </span><span>1</span><span>),</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;#949494&quot;</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>0.4</span><span>,</span><span> </span><span>lty</span><span> </span><span>=</span><span> </span><span>1</span><span>)</span><span> </span><span>+</span><span>
</span><span>facet_wrap</span><span>(</span><span>~</span><span>Pokemon</span><span>)</span><span> </span><span>+</span><span>
</span><span>coord_polar</span><span>()</span><span> </span><span>+</span><span> </span><span>scale_fill_manual</span><span>(</span><span>values</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;#06AED5&quot;</span><span>,</span><span>&quot;#ED933C&quot;</span><span>,</span><span> </span><span>&quot;#65B54F&quot;</span><span>))</span><span> </span><span>+</span><span> </span><span>scale_y_continuous</span><span>(</span><span>
</span><span>limits</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>0</span><span>,</span><span> </span><span>6</span><span>),</span><span> </span><span>breaks</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>2</span><span>,</span><span> </span><span>3</span><span>,</span><span> </span><span>4</span><span>,</span><span> </span><span>5</span><span>,</span><span> </span><span>6</span><span>))</span><span> </span><span>+</span><span> </span><span>labs</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>)</span><span> </span><span>+</span><span> </span><span>theme</span><span>(</span><span>
</span><span>panel.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;#FFFFFF&quot;</span><span>),</span><span>
</span><span>plot.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;#FFFFFF&quot;</span><span>),</span><span>
</span><span>strip.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;#FFFFFF&quot;</span><span>),</span><span>
</span><span>strip.text</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>10</span><span>),</span><span>
</span><span>panel.grid</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.ticks</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.text.y</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.text.x</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>7</span><span>),</span><span>
</span><span>panel.spacing</span><span> </span><span>=</span><span> </span><span>grid</span><span>::</span><span>unit</span><span>(</span><span>2</span><span>,</span><span> </span><span>&quot;lines&quot;</span><span>))</span><span>
</span></code></pre>
</div>
<p><img alt="center" src="https://i0.wp.com/www.maxhumber.com/assets/img/the_best_4.png?w=456" data-recalc-dims="1"></p>
<p>And we can see that there really is no objective “Best” this time. It totally depends on what measures are important to us. Perhaps, I really value Speed and Attack in my Pokemon. Well, looking at the graph I can see that I ought to grab Charizard. And you might decide to go with Blastoise because you like big tanky defense pokemon. It totally depends! And single point value would be incredibly misleading here.</p>
<h1>Cities</h1>
<p>Just one last example to wrap it all up. Using the PWC <a target="_blank" rel="nofollow" href="http://www.pwc.com/us/en/cities-of-opportunity.html">Cities of Opportunity Index</a> I can grab the measures that are important me, like, Broadband Quality (need that fast internet!), Entertainment, Quality of Living, Ease of Starting a Business, and Cost of Living to generate similar comparisons.</p>
<p>PWC actually has a visulatization tool that spits out:</p>
<p><img alt="center" src="https://i0.wp.com/www.maxhumber.com/assets/img/the_best_5.png?w=456" data-recalc-dims="1"></p>
<p>But I think my bubbles are better!</p>
<div>
<pre><code><span>df</span><span> </span><span>&lt;-</span><span> </span><span>tribble</span><span>(</span><span>
</span><span>~</span><span>city</span><span>,</span><span> </span><span>~</span><span>Broadband</span><span>,</span><span> </span><span>~</span><span>Entertainment</span><span>,</span><span> </span><span>~</span><span>`QOL`</span><span>,</span><span> </span><span>~</span><span>Startup</span><span>,</span><span> </span><span>~</span><span>`COL`</span><span>,</span><span>
</span><span>&quot;Toronto&quot;</span><span>,</span><span> </span><span>17</span><span>,</span><span> </span><span>16</span><span>,</span><span> </span><span>30</span><span>,</span><span> </span><span>30</span><span>,</span><span> </span><span>12</span><span>,</span><span> </span><span>&quot;London&quot;</span><span>,</span><span> </span><span>19</span><span>,</span><span> </span><span>30</span><span>,</span><span> </span><span>16</span><span>,</span><span> </span><span>20</span><span>,</span><span> </span><span>1</span><span>,</span><span>
</span><span>&quot;San Francisco&quot;</span><span>,</span><span> </span><span>20</span><span>,</span><span> </span><span>13</span><span>,</span><span> </span><span>18</span><span>,</span><span> </span><span>18</span><span>,</span><span> </span><span>6</span><span>)</span><span> </span><span>%>%</span><span>
</span><span>gather</span><span>(</span><span>stat</span><span>,</span><span> </span><span>value</span><span>,</span><span> </span><span>-</span><span>city</span><span>)</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>score</span><span> </span><span>=</span><span> </span><span>value</span><span> </span><span>%/%</span><span> </span><span>6</span><span> </span><span>+</span><span> </span><span>1</span><span>)</span><span> </span><span>%>%</span><span> </span><span>mutate</span><span>(</span><span>order</span><span> </span><span>=</span><span> </span><span>recode</span><span>(</span><span>
</span><span>stat</span><span>,</span><span> </span><span>Broadband</span><span> </span><span>=</span><span> </span><span>5</span><span>,</span><span> </span><span>Entertainment</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>COL</span><span> </span><span>=</span><span> </span><span>2</span><span>,</span><span> </span><span>QOL</span><span> </span><span>=</span><span> </span><span>3</span><span>,</span><span> </span><span>Startup</span><span> </span><span>=</span><span> </span><span>4</span><span>))</span><span>
</span><span>df</span><span> </span><span>%>%</span><span> </span><span>ggplot</span><span>(</span><span>aes</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>fct_reorder</span><span>(</span><span>stat</span><span>,</span><span> </span><span>order</span><span>),</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>score</span><span>,</span><span> </span><span>fill</span><span> </span><span>=</span><span> </span><span>city</span><span>))</span><span> </span><span>+</span><span> </span><span>geom_col</span><span>(</span><span>alpha</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>width</span><span> </span><span>=</span><span> </span><span>1</span><span>,</span><span> </span><span>show.legend</span><span> </span><span>=</span><span> </span><span>FALSE</span><span>,</span><span> </span><span>color</span><span> </span><span>=</span><span> </span><span>&quot;white&quot;</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_hline</span><span>(</span><span>yintercept</span><span> </span><span>=</span><span> </span><span>seq</span><span>(</span><span>0</span><span>,</span><span> </span><span>6</span><span>,</span><span> </span><span>by</span><span> </span><span>=</span><span> </span><span>1</span><span>),</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;#949494&quot;</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>0.5</span><span>,</span><span> </span><span>lty</span><span> </span><span>=</span><span> </span><span>3</span><span>)</span><span> </span><span>+</span><span>
</span><span>geom_vline</span><span>(</span><span>xintercept</span><span> </span><span>=</span><span> </span><span>seq</span><span>(</span><span>0.5</span><span>,</span><span> </span><span>5.5</span><span>,</span><span> </span><span>1</span><span>),</span><span> </span><span>colour</span><span> </span><span>=</span><span> </span><span>&quot;#949494&quot;</span><span>,</span><span> </span><span>size</span><span> </span><span>=</span><span> </span><span>0.4</span><span>,</span><span> </span><span>lty</span><span> </span><span>=</span><span> </span><span>1</span><span>)</span><span> </span><span>+</span><span>
</span><span>facet_wrap</span><span>(</span><span>~</span><span>city</span><span>)</span><span> </span><span>+</span><span>
</span><span>coord_polar</span><span>()</span><span> </span><span>+</span><span> </span><span>scale_fill_manual</span><span>(</span><span>values</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>&quot;#0C2238&quot;</span><span>,</span><span>&quot;#BF4E22&quot;</span><span>,</span><span> </span><span>&quot;#AF0023&quot;</span><span>))</span><span> </span><span>+</span><span> </span><span>scale_y_continuous</span><span>(</span><span>
</span><span>limits</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>0</span><span>,</span><span> </span><span>6</span><span>),</span><span> </span><span>breaks</span><span> </span><span>=</span><span> </span><span>c</span><span>(</span><span>1</span><span>,</span><span> </span><span>2</span><span>,</span><span> </span><span>3</span><span>,</span><span> </span><span>4</span><span>,</span><span> </span><span>5</span><span>,</span><span> </span><span>6</span><span>))</span><span> </span><span>+</span><span> </span><span>labs</span><span>(</span><span>x</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>,</span><span> </span><span>y</span><span> </span><span>=</span><span> </span><span>&quot;&quot;</span><span>)</span><span> </span><span>+</span><span> </span><span>theme</span><span>(</span><span>
</span><span>panel.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;#FFFFFF&quot;</span><span>),</span><span>
</span><span>plot.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;#FFFFFF&quot;</span><span>),</span><span>
</span><span>strip.background</span><span> </span><span>=</span><span> </span><span>element_rect</span><span>(</span><span>fill</span><span> </span><span>=</span><span> </span><span>&quot;#FFFFFF&quot;</span><span>),</span><span>
</span><span>strip.text</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>10</span><span>),</span><span>
</span><span>panel.grid</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.ticks</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.text.y</span><span> </span><span>=</span><span> </span><span>element_blank</span><span>(),</span><span>
</span><span>axis.text.x</span><span> </span><span>=</span><span> </span><span>element_text</span><span>(</span><span>size</span><span> </span><span>=</span><span> </span><span>7</span><span>),</span><span>
</span><span>panel.spacing</span><span> </span><span>=</span><span> </span><span>grid</span><span>::</span><span>unit</span><span>(</span><span>2</span><span>,</span><span> </span><span>&quot;lines&quot;</span><span>))</span><span>
</span></code></pre>
</div>
<p><img alt="center" src="https://i0.wp.com/www.maxhumber.com/assets/img/the_best_6.png?w=456" data-recalc-dims="1"></p>
<p>There you have it. “The Best” Visualization. Or at least a visualization for “The Best”.</p>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://www.maxhumber.com/2017/01/21/THE-BEST.html"> max humber</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/1v1zwSt38Jw"></a></div>