<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/my-best9of2018-tweets/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://masalmon.eu/2018/12/28/best9of2018/"> Posts on Maëlle's R blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>As 2018 nears its end, it’s time for me to look back on my R/Twitter<br>
year with the same simple method as <a rel="nofollow" href="https://masalmon.eu/2017/12/30/best9of2017/" target="_blank">last<br>
year</a>: let me identify and webshoot my 9 best<br>
tweets of 2018!</p>

<h1>Downloading and opening my Twitter data</h1>
<p>Like in 2017 I tweeted too much and therefore was unable to rely on<br>
<code>rtweet::get_timeline()</code> (or <code>rtweet::get_my_timeline()</code>) to download my<br>
tweets so I exported data via the Tweets tab of<br>
<a rel="nofollow" href="https://analytics.twitter.com/" target="_blank">https://analytics.twitter.com/</a>. Last year, I downloaded one file per<br>
quarter but somehow had to download one per month this time. It was<br>
monotonous but not horrible.</p>
<pre><code>library(&quot;magrittr&quot;)

dir(&quot;data&quot;, full.names = TRUE) %>%
  purrr::map_df(readr::read_csv) %>%
  unique() -> my_tweets
</code></pre>
<p>4196 tweets!</p>
<h1>Getting the top 9 tweets</h1>
<p>Similarly to my 2017 post, I chose the number of likes as criterion to<br>
define my best tweets.</p>
<pre><code>my_tweets &lt;- dplyr::arrange(my_tweets, - likes)
my_tweets &lt;- janitor::clean_names(my_tweets)

knitr::kable(my_tweets[1:9, &quot;likes&quot;])
</code></pre>
<table>
<thead>
<tr>
<th align="right">likes</th>
</tr>
</thead>
<tbody>
<tr>
<td align="right">162</td>
</tr>
<tr>
<td align="right">151</td>
</tr>
<tr>
<td align="right">128</td>
</tr>
<tr>
<td align="right">112</td>
</tr>
<tr>
<td align="right">95</td>
</tr>
<tr>
<td align="right">94</td>
</tr>
<tr>
<td align="right">91</td>
</tr>
<tr>
<td align="right">86</td>
</tr>
<tr>
<td align="right">75</td>
</tr>
</tbody>
</table>
<pre><code>best9 &lt;- my_tweets$tweet_permalink[1:9]
</code></pre>
<p>The table above shows that my best tweets were not <em>extremely</em> popular.</p>
<h1>Webshooting and combining the tweets</h1>
<p>My 2017 blog post inspired Bob Rudis to contribute a <code>tweet_shot()</code><br>
function to <code>rtweet</code>, relying on the <code>webshot</code> package, so that’s what I<br>
used.</p>
<pre><code>shot &lt;- function(permalink){
  rtweet::tweet_shot(permalink) %>%
    magick::image_crop(magick::geometry_area(width = 517,
                                             height = 517,
                       y_off = 88)) %>%
    magick::image_border(&quot;salmon&quot;, &quot;20x20&quot;)
}

images &lt;- purrr::map(as.character(best9),
                     shot)
</code></pre>
<p>I improved the collage code with two tweaks:</p>
<ul>
<li>
<p>I created rows then columns instead of the other way round, because<br>
that’s what Instagram does. I did not pay attention to this last<br>
year but Andrew Caines told me this in a comment.</p>
</li>
<li>
<p>I did not save the intermediary images to disk. I’ve upped my<br>
<code>magick</code> game!</p>
</li>
</ul>
<pre><code>make_row &lt;- function(i, images){
  images[((i-1)*3+1):((i-1)*3+3)] %>%
    magick::image_join() %>%
    magick::image_append()
}

purrr::map(1:3, make_row,
           images = images) %>%
  magick::image_join() %>%
  magick::image_append(stack = TRUE) %>%
  magick::image_border(&quot;salmon&quot;, &quot;20x20&quot;)
</code></pre>
<p><img alt="best 9 of 2018" src="https://i2.wp.com/masalmon.eu/figure/source/2018-12-28-best9of2018/best9.png?w=450&ssl=1" data-recalc-dims="1"></p>
<p>Worth noting from my R year are, according to these tweets,</p>
<ul>
<li>
<p>my re-designing <a rel="nofollow" href="https://masalmon.eu/" target="_blank">my website</a>;</p>
</li>
<li>
<p>the slides of my R-Ladies Strasbourg talk <a rel="nofollow" href="https://maelle.github.io/fluctuat_nec_mergitur/" target="_blank">about how to be a<br>
resilient R user</a>;</p>
</li>
<li>
<p>my <a rel="nofollow" href="https://masalmon.eu/bio/" target="_blank">starting work</a> at rOpenSci and Locke<br>
Data (yay!);</p>
</li>
<li>
<p>my blog post about <a rel="nofollow" href="https://masalmon.eu/2018/01/07/rainbowing/" target="_blank">rainbowing a set of<br>
pictures</a>;</p>
</li>
<li>
<p>another blog post featuring <code>magick</code>, about <a rel="nofollow" href="https://masalmon.eu/2018/02/22/hexcombine/" target="_blank">combining<br>
hexes</a> but I’d recommend<br>
reading <a rel="nofollow" href="https://blog.mitchelloharawild.com/blog/user-2018-feature-wall/" target="_blank">this post by Mitchell O’Hara<br>
Wild</a><br>
instead;</p>
</li>
<li>
<p>my blog post about <a rel="nofollow" href="https://masalmon.eu/2018/07/22/wheretogethelp/" target="_blank">where to get R<br>
help</a> that might be<br>
the personal blog post I’m the proudest of.</p>
</li>
</ul>
<p>What about your R year, on Twitter and elsewhere? Have a good last days<br>
of 2018, and a happy 2019!</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="https://masalmon.eu/2018/12/28/best9of2018/"> Posts on Maëlle's R blog</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 rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/nO-d8ovpi8s" height="1"></a></div>