Skip to content

Instantly share code, notes, and snippets.

@samclifford
Created March 3, 2021 22:27
Show Gist options
  • Save samclifford/2dced2020e89c235103d3083fbdce978 to your computer and use it in GitHub Desktop.
Save samclifford/2dced2020e89c235103d3083fbdce978 to your computer and use it in GitHub Desktop.
library(tidyverse)
expand.grid(day = 1:7, week = 1:13) %>%
mutate(mu = 3*sin(day*2*pi/7)) %>%
mutate(p = boot::inv.logit(mu)) %>%
mutate(obs = rbinom(n(), size = 1, p = p),
pred = rbinom(n(), size = 1, p = p)) %>%
gather(key, value, obs, pred) %>%
mutate(value = factor(value)) %>%
ggplot(data =., aes(x = day, y = key)) +
geom_tile(aes(fill = value)) +
coord_equal() +
facet_grid(week ~ .)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment