Skip to content

Instantly share code, notes, and snippets.

@tmastny
Created April 28, 2020 22:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmastny/4f56dfd709b268609f4ff9227e87fe83 to your computer and use it in GitHub Desktop.
Save tmastny/4f56dfd709b268609f4ff9227e87fe83 to your computer and use it in GitHub Desktop.
library(tidytext)
library(ggplot2)
library(dplyr)
diamonds %>%
filter(cut %in% c("Fair", "Good")) %>%
count(price = ifelse(price < 2500, "lo", "hi"), cut, clarity) %>%
mutate(clarity = reorder_within(clarity, n, cut)) %>%
ggplot(aes(clarity, n)) +
geom_col() +
facet_wrap(cut ~ price, scales = "free", ncol = 2) +
scale_x_reordered() +
coord_flip()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment