<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/mix-ggplot2-graphs-with-your-favorite-memes-memery-0-4-2-released/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://blog.snap.uaf.edu/2018/02/15/mix-ggplot2-graphs-with-your-favorite-memes-memery/"> rbloggers – SNAP tech blog</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Make memorable plots with memery. <code>memery</code> is an R package that generates internet memes including superimposed inset graphs and other atypical features, combining the visual impact of an attention-grabbing meme with graphic results of data analysis. <a rel="nofollow" href="https://cran.r-project.org/web/packages/memery/" target="_blank">Version 0.4.2</a> of <code>memery</code> is now on CRAN. The latest development version and a package vignette are available on <a rel="nofollow" href="https://github.com/leonawicz/memery" target="_blank">GitHub</a>.</p>
<p><span></span></p>
<p>[<a rel="nofollow" href="https://leonawicz.github.io/blog/post/2018-02-09-mix-ggplot2-graphs-with-your-favorite-memes-memery-0-4-2-on-cran/" target="_blank">original post</a>]</p>
<h2>Changes in v0.4.2</h2>
<p>This latest version of <code>memery</code> includes a demo Shiny app.</p>
<pre>
library(memery)
memeApp()
</pre>
<p>Animated gif support is now also included (example below). This relies on the <code>magick</code> package and ImageMagick software, but this is optional and these libraries are not required for you to use <code>memery</code> if you have no interest in animated gifs. For example, when launching the demo Shiny app, if you do not have these libraries installed on your system, the app launches in your browser in a simplified form. It will only accept png and jpg files as inputs and a default static image will be shown at startup. Alternatively, the app launches in full mode, will also accept gif inputs, and the default image shown is an animated gif. The only function in <code>memery</code> that pertains to gifs is <code>meme_gif</code>, which is distinct from the main package function, <code>meme</code>. If you call <code>meme_gif</code> without the supporting libraries, it simply prints a notification about this to the console.</p>
<h2>Example usage</h2>
<p>Below is an example interleaving a semi-transparent ggplot2 graph between a meme image backdrop and overlying meme text labels. The <code>meme</code> function will produce basic memes without needing to specify a number of additional arguments, but this is not the main purpose of the package. Adding a plot is then as simple as passing the plot to <code>inset</code>.</p>
<p><code>memery</code> offers sensible defaults as well as a variety of basic templates for controlling how the meme and graph are spliced together. The example here shows how additional arguments can be specified to further control the content and layout. See the package <a rel="nofollow" href="https://leonawicz.github.io/memery/articles/memery.html" target="_blank">vignette</a> for a more complete set of examples and description of available features and graph templates.</p>
<p>Please do share your data analyst meme creations. Enjoy!</p>
<pre>
library(memery)
 
# Make a graph of some data
library(ggplot2)
x &lt;- seq(0, 2*pi , length.out = 50)
panels &lt;- rep(c(&quot;Plot A&quot;, &quot;Plot B&quot;), each = 50)
d &lt;- data.frame(x = x, y = sin(x), grp = panels)
txt &lt;- c(&quot;Philosoraptor's plots&quot;, &quot;I like to make plots&quot;, 
         &quot;Figure 1. (A) shows a plot and (B) shows another plot.&quot;)
p &lt;- ggplot(d, aes(x, y)) + geom_line(colour = &quot;cornflowerblue&quot;, size = 2) +
            geom_point(colour = &quot;orange&quot;, size = 4) + facet_wrap(~grp) +
            labs(title = txt[1], subtitle = txt[2], caption = txt[3])
 
# Meme settings
img &lt;- system.file(&quot;philosoraptor.jpg&quot;, package = &quot;memery&quot;) # image
lab &lt;- c(&quot;What to call my R package?&quot;, &quot;Hmm... What? raptr is taken!?&quot;, &quot;Noooooo!!!!&quot;) # labels
size &lt;- c(1.8, 1.5, 2.2) # label sizes, positions, font families and colors
pos &lt;- list(w = rep(0.9, 3), h = rep(0.3, 3), x = c(0.45, 0.6, 0.5), y = c(0.95, 0.85, 0.3))
fam &lt;- c(&quot;Impact&quot;, &quot;serif&quot;, &quot;Impact&quot;)
col &lt;- list(c(&quot;black&quot;, &quot;orange&quot;, &quot;white&quot;), c(&quot;white&quot;, &quot;black&quot;, &quot;black&quot;))
gbg &lt;- list(fill = &quot;#FF00FF50&quot;, col = &quot;#FFFFFF75&quot;) # graph background
 
# Save meme
meme(img, lab, &quot;meme.jpg&quot;, size = size, family = fam, col = col[[1]],
     shadow = col[[2]], label_pos = pos, inset = p, inset_bg = gbg, mult = 2)
</pre>
<p><a rel="nofollow" href="https://uasnap.files.wordpress.com/2017/11/meme.jpg" target="_blank"><img data-orig-file="https://uasnap.files.wordpress.com/2017/11/meme.jpg" data-orig-size="1000,1000" data-medium-file="https://uasnap.files.wordpress.com/2017/11/meme.jpg?w=300" data-attachment-id="1437" data-image-meta="{" data-image-description="" src="https://uasnap.files.wordpress.com/2017/11/meme.jpg?w=450&h=774&fit=774%2C774" data-permalink="https://blog.snap.uaf.edu/?attachment_id=1437" data-large-file="https://uasnap.files.wordpress.com/2017/11/meme.jpg?w=450&amp;h=774&amp;fit=774%2C774" alt="" data-image-title="meme" sizes="(max-width: 774px) 100vw, 774px" data-comments-opened="0" class="wp-image-1437" data-recalc-dims="1"></a></p>
<h2>Animated gif example</h2>
<pre>
d$grp &lt;- gsub(&quot;Plot&quot;, &quot;Cat's Plot&quot;, d$grp)
p &lt;- ggplot(d, aes(x, y)) + geom_line(colour = &quot;white&quot;, size = 2) +
  geom_point(colour = &quot;orange&quot;, size = 1) + facet_wrap(~grp) +
  labs(title = &quot;The wiggles&quot;, subtitle = &quot;Plots for cats&quot;,
       caption = &quot;Figure 1. Gimme sine waves.&quot;)
lab &lt;- c(&quot;R plots for cats&quot;, &quot;Sine wave sine wave...&quot;)
pos &lt;- list(w = rep(0.9, 2), h = rep(0.3, 2), x = rep(0.5, 2), y = c(0.9, 0.75))
img &lt;- &quot;http://forgifs.com/gallery/d/228621-4/Cat-wiggles.gif&quot;
meme_gif(img, lab, &quot;sine.gif&quot;, size = c(1.5, 0.75), label_pos = pos,
         inset = p, inset_bg = list(fill = &quot;#00BFFF80&quot;), fps = 20)
</pre>
<p align="center"><img src="https://i0.wp.com/github.com/leonawicz/DataVisExamples/blob/master/packages/memery.gif?w=456&ssl=1" data-recalc-dims="1"></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://blog.snap.uaf.edu/2018/02/15/mix-ggplot2-graphs-with-your-favorite-memes-memery/"> rbloggers – SNAP tech 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 alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/i70rmHWAgMw" height="1"></a></div>