Skip to content

Instantly share code, notes, and snippets.

@hrbrmstr
Created March 13, 2018 15:18
Show Gist options
  • Save hrbrmstr/42aff98aca45d29f4cda5e731bacdd8d to your computer and use it in GitHub Desktop.
Save hrbrmstr/42aff98aca45d29f4cda5e731bacdd8d to your computer and use it in GitHub Desktop.
library(waffle)
library(viridis)
library(tidyverse)
data_frame(
country = c("Rest of World", "Canada*", "Brazil*", "South Korea", "Mexico",
"Russia", "Turkey", "Japan", "Taiwan", "Germany", "India"),
pct = c(22, 16, 13, 10, 9, 9, 7, 5, 4, 3, 2)
) %>%
mutate(country = sprintf("%s (%s%%)", country, pct)) %>%
waffle(
colors = c("gray70", viridis_pal(option = "plasma")(10))
) +
labs(
title = "U.S. Steel Imports — YTD 2017 Percent of Volume",
subtitle = "Ten nations account for ~80% of U.S. steel imports.",
caption = "Source: IHS Global Trade Atlas • YTD through September 2017\n* Canada & Brazil are not impacted by the proposed tariffs"
) +
theme_ipsum_ps() +
theme(legend.position = "top") +
theme(axis.text = element_blank()) +
theme(title = element_text(hjust=0.5)) +
theme(plot.title = element_text(hjust=0.5)) +
theme(plot.subtitle = element_text(hjust=0.5)) +
theme(plot.caption = element_text(hjust=1))
@emilelatour
Copy link

I had this issue also when I was using version 0.7.0 of the waffle package. When I installed the development version (0.8.0), this resolved the error.

devtools::install_github("hrbrmstr/waffle")

@mschnetzer
Copy link

mschnetzer commented Mar 18, 2018

Thank you so much for your helpful answer. It worked perfectly!

@hrbrmstr
Copy link
Author

hrbrmstr commented Apr 8, 2018

My IFTTT rule to notify abt gist comments magically started working again. Unfortunately I missed this. Issues on the repo may not get addressed immediately but they'll generally be seen earlier than gist comments (there's no built-in notification for gist comments)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment