You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/post/2019-08-28-you-can-replicate-almost-any-plot-with-ggplot2.Rmd
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ Although R is great for quickly turning data into plots, it is not widely used f
9
9
10
10
Here I show five charts from the lay press that I use as examples in my data science courses. In the past I would show the originals, but I decided to replicate them in R to make it possible to generate class notes with just R code (there was a lot of googling involved).
11
11
12
-
Below I show the original figures followed by R code and the version of the plot it produces. I used the__ggplot2__ package but you can achieve similar results using other packages or even just with R-base. Any recommendations on how to improve the code or links to other good examples are welcomed. Please at to the comments or @ me on twitter:[@rafalab](https://twitter.com/rafalab).
12
+
Below I show the original figures followed by R code and the version of the plot it produces. I used the__ggplot2__ package but you can achieve similar results using other packages or even just with R-base. Any recommendations on how to improve the code or links to other good examples are welcomed. Please at to the comments or @ me on twitter:[\@rafalab](https://twitter.com/rafalab).
Copy file name to clipboardExpand all lines: content/post/2019-08-28-you-can-replicate-almost-any-plot-with-ggplot2.html
+8-8Lines changed: 8 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
10
10
<p>Although R is great for quickly turning data into plots, it is not widely used for making publication ready figures. But, with enough tinkering you can make almost any plot in R. For examples check out the<ahref="https://flowingdata.com/">flowingdata blog</a> or the<ahref="https://serialmentor.com/dataviz/index.html">Fundamentals of Data Visualization book</a>.</p>
11
11
<p>Here I show five charts from the lay press that I use as examples in my data science courses. In the past I would show the originals, but I decided to replicate them in R to make it possible to generate class notes with just R code (there was a lot of googling involved).</p>
12
-
<p>Below I show the original figures followed by R code and the version of the plot it produces. I used the<strong>ggplot2</strong> package but you can achieve similar results using other packages or even just with R-base. Any recommendations on how to improve the code or links to other good examples are welcomed. Please at to the comments or @ me on twitter:<spanclass="citation">[@rafalab]</span>(<ahref="https://twitter.com/rafalab"class="uri">https://twitter.com/rafalab</a>).</p>
12
+
<p>Below I show the original figures followed by R code and the version of the plot it produces. I used the<strong>ggplot2</strong> package but you can achieve similar results using other packages or even just with R-base. Any recommendations on how to improve the code or links to other good examples are welcomed. Please at to the comments or @ me on twitter:<ahref="https://twitter.com/rafalab">@rafalab</a>.</p>
13
13
<divid="example-1"class="section level2">
14
14
<h2>Example 1</h2>
15
15
<p>The first example is from<ahref="https://abcnews.go.com/blogs/headlines/2012/12/us-gun-ownership-homicide-rate-higher-than-other-developed-countries/">this</a> ABC news article. Here is the original:</p>
@@ -90,7 +90,7 @@ <h2>Example 3</h2>
90
90
91
91
dat %>% mutate(state = reorder(state, desc(state))) %>%