https://github.com/bgreenwell/imgflipr
An R Wrapper to the Official Imgflip API
https://github.com/bgreenwell/imgflipr
Last synced: about 2 months ago
JSON representation
An R Wrapper to the Official Imgflip API
- Host: GitHub
- URL: https://github.com/bgreenwell/imgflipr
- Owner: bgreenwell
- Created: 2019-02-11T21:03:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-02-12T02:13:56.000Z (over 6 years ago)
- Last Synced: 2025-02-02T00:48:29.186Z (4 months ago)
- Language: R
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# imgflipr
The goal of imgflipr is to, you guessed it, interact with the official [Imgflip API](https://api.imgflip.com/) through R. For making custom memes, check out the R `r emo::ji("package")` [meme](https://github.com/GuangchuangYu/meme/).
## Installation
Currently, you can only install this package from GitHub:
```{r, eval=FALSE}
devtools::install_github("bgreenwell/imgflipr")
```## Example
Grab a tibble of the most popular memes:
```{r example}
memes <- imgflipr::get_memes()
memes
```Grab the ID for a particular image:
```{r memes}
batman <- memes[memes$name == "Batman Slapping Robin", "id"]
```Caption this image (note, I have my [Imgflip](https://imgflip.com/) username and password stored as an environment variable in my `.Renviron` file):
```{r caption-image}
url <- imgflipr::caption_image(
template_id = batman,
username = Sys.getenv("IMGFLIP_USERNAME"),
password = Sys.getenv("IMGFLIP_PASSWORD"),
text0 = "When should I use pie charts?",
text1 = "Never!"
)
url
```For now, just visit the link to your captioned image, it's that easy! Alternatively, you can include the captioned image in R markdown by passing the resulting URL to `knitr::include_graphics()`:
```{r view-image, out.width="50%", fig.align="center"}
knitr::include_graphics(url)
```