Skip to content

Instantly share code, notes, and snippets.

@bhive01
Created January 19, 2018 02:29
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 bhive01/1c35f53904d4085d3e8f948e9c1fa19b to your computer and use it in GitHub Desktop.
Save bhive01/1c35f53904d4085d3e8f948e9c1fa19b to your computer and use it in GitHub Desktop.
library(tidyverse)
lagshow <-
data.frame(x= rep(1:10, 14),
y = rep(1:10, 14),
color = rep(rep(c("A", "B"), each = 10), 7),
lag = rep(-3:3, each=20)
) %>%
mutate(x = if_else(color == "A", x-lag, x))
ggplot(lagshow, aes(x = x, y = y, colour = color, shape = color)) +
geom_point() +
geom_line() +
facet_grid(.~lag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment