You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 line
833B

  1. # Animated dplyr joins with gganimate
  2. # * Garrick Aden-Buie
  3. # * garrickadenbuie.com
  4. # * MIT License: https://opensource.org/licenses/MIT
  5. library(tidyverse)
  6. library(gganimate)
  7. if (!getOption("tidy_verb_anim.font_registered", FALSE)) {
  8. source(here::here("R", "01_register-fonts.R"))
  9. }
  10. if (!getOption("tidy_verb_anim.functions_loaded", FALSE)) {
  11. source(here::here("R", "02_functions.R"))
  12. }
  13. source(here::here("R", "03_check-folders.R"))
  14. plot_data_join <- function(x, title = "", xlims = xlim(0.5, 5.5), ylims = ylim(-3.5, -0.5)) {
  15. plot_data(x, title) +
  16. xlims + ylims
  17. }
  18. # Data ----
  19. x <- data_frame(
  20. id = 1:3,
  21. x = paste0("x", 1:3)
  22. )
  23. y <- data_frame(
  24. id = (1:4)[-3],
  25. y = paste0("y", (1:4)[-3])
  26. )
  27. initial_join_dfs <- proc_data(x, "x") %>%
  28. bind_rows(mutate(proc_data(y, "y"), .x = .x + 3)) %>%
  29. mutate(frame = 1)