Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

36 lines
843B

  1. # Animated dplyr joins with gganimate
  2. # * Garrick Aden-Buie
  3. # * garrickadenbuie.com
  4. # * MIT License: https://opensource.org/licenses/MIT
  5. # Note: I used Fira Sans and Fira Mono fonts.
  6. # Use search and replace to use a different font if Fira is not available.
  7. library(tidyverse)
  8. library(gganimate)
  9. if (!getOption("tidy_verb_anim.font_registered", FALSE)) {
  10. source(here::here("R", "01_register-fonts.R"))
  11. }
  12. if (!getOption("tidy_verb_anim.functions_loaded", FALSE)) {
  13. source(here::here("R", "02_functions.R"))
  14. }
  15. if (!dir.exists(here::here("images"))) dir.create(here::here("images"))
  16. # Data ----
  17. x <- data_frame(
  18. id = 1:3,
  19. x = paste0("x", 1:3)
  20. )
  21. y <- data_frame(
  22. id = (1:4)[-3],
  23. y = paste0("y", (1:4)[-3])
  24. )
  25. initial_dfs <- proc_data(x, "x") %>%
  26. bind_rows(mutate(proc_data(y, "y"), .x = .x + 3)) %>%
  27. mutate(frame = 1)