I having been prepping for my lightning talk at the R-Ladies Sydney Birthday this weekend and learning about all the packages that you can use to make memes in R. I’m going going to talk about my favourite option (which is the
memery package), but here is what I learned about other packages.
memer package by Sam Tyner is a tidyverse compatible package that allows you to replace text in popular memes with your own.
Check out the memer vignette here.
##  "AllTheThings" "AmericanChopper" "AncientAliens" ##  "BatmanRobin" "DistractedBf" "EvilKermit" ##  "ExpandingBrain" "FirstWorldProbs" "FryNotSure" ##  "HotlineDrake" "IsThisAPigeon" "NoneOfMyBusiness" ##  "CheersLeo" "OneDoesNotSimply" "DosEquisMan" ##  "OffRamp" "OprahGiveaway" "Philosoraptor" ##  "PicardFacePalm" "PicardWTH" "Purples" ##  "PutItPatrick" "Rainbow" "ShiaJustDoIt" ##  "Spongebob" "SuccessKid" "ThatWouldBeGreat" ##  "TheRockDriving" "ThinkAboutIt" "TrumpBillSigning" ##  "TwoButtonsAnxiety" "WhatIfIToldYou" "CondescendingWonka" ##  "YoDawg" "Y-U-NOguy"
meme_get("OprahGiveaway") %>% meme_text_bottom("Happy Birthday \n R-Ladies Sydney!")
Some memes of the memes that come with the
memer package have more than 1 text field. Thank you Mr Trump.
meme_get("TrumpBillSigning") %>% meme_text_trump("R-Ladies Sydney", "Happy Birthday")
If you have the
rtweet package and a twitter token set up, you can tweet your meme straight from R using the meme_tweet() function. I didn’t work that out… yet.
You can use the
meme package by GuangchuangYu to add meme text to any image.
Check out the meme vignette here.
note: I had much more difficulty making this package work. You need to have the
sysfontspackage, and if on a Mac, it might help to install XQuartz. See issue here
note: both the
memepackage and the
memerypackage below have a meme() function. Use package::function to specify which one you want to use.
The example from the vignette loads an image that is in the meme package (using the
system.file() function) and adds text on top.
pic1 <- system.file("success.jpg", package="meme") meme::meme(pic1, "code", "all the things!")
But you can load any image and add text to it.
meme::meme("kitten.jpg", "am i in your way?")
A bit like ggsave() you can use meme_save() to save memes to jpg or png.
library(tidyverse) #so you can pipe
meme::meme("kitten.jpg", "am i in your way?") %>% meme_save("kitty.jpg")
memery package by Matthew Leonawicz ended up being my favourite option because it is easy to make basic memes as above, but you can also make memed gifs, integrate ggplots AND there is a shiny app associated with it.
Check out the memery vignette here.
note: both the
memepackage and the
memerypackage have a meme() function. Use package::function to specify which one you want to use.
The example in the vignette first loads a picture from the package (again using the
pic <- system.file("philosoraptor.jpg", package = "memery")
Then defines a list of text possibilities.
txt <- c("What to call my R package?", "Perhaps...")
Then the makes a meme by putting the pic and text together, and saves to jpg, all in one step.
reknitting my blog and this is now throwing an error “Error in showtext_begin_internal(record = FALSE) : no active graphics device”
memery::meme(pic, txt, "dino1.jpg")
You can also get the pic from the internet.
web <- "https://imgflip.com/s/meme/Philosoraptor.jpg" memery::meme(web, txt, "dino2.png")
It is super easy to add meme text to your own image. If your list of text possibilities is 2 items long and you don’t specify which to use (as above txt), it will by default put text at the top and bottom. Here we use the kitten.jpg image again.
txt2 <- c("Am I in your way?", "I'm too cute to work!") memery::meme("kitten.jpg", txt2, "kitty1.jpg")
You can also change the colour and shadow of the text by defining a list of clrs (colours), and then calling col (for colour) and shadow.
clrs <- c("blue", "pink") memery::meme("kitten.jpg", txt2, "kitty2.jpg", col = clrs, shadow = clrs)
memery package also has a meme_gif() function will take a gif link and overlay meme text on it.
img <- "https://media.giphy.com/media/OUwzqE4ZOk5Bm/giphy.gif" lab <- c("memery", "magic") pos <- list(w = rep(0.9, 2), h = rep(0.3, 2), x = rep(0.5, 2), y = c(0.9, 0.75)) meme_gif(img, lab, "HP.gif", size = c(1.5, 0.75), label_pos = pos, fps = 20)
I didn’t really work out the size and position on this one and I’m not sure why the frames are flickery, so it needs some work. But you get the idea.
memeryalso has a shiny app
memery package has a shiny app that you can call using memeApp(). It is designed to demo the package. Read about it here.
#Option 4: Are you looking for a meme project ?
In my googling, I also found another package called
meme by Thomas Leeper that is not currently being maintained. It uses the memecaptain API and the link to those meme templates is currently broken. If you are looking for a super fun project, this meme package is looking for a new maintainer!