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.

49 satır
1.1KB

  1. source(here::here("R/00_base_join.R"))
  2. initial_join_dfs <- initial_join_dfs %>%
  3. arrange(.x, .y) %>%
  4. mutate(.obj = row_number(), .obj = .obj + 90 * as.integer(.id == "y"))
  5. aj_step2 <- initial_join_dfs %>%
  6. filter(.id == "x" | value %in% paste(1:2)) %>%
  7. mutate(frame = 2,
  8. .x = ifelse(.id == "y", 2.5, .x + 1.5),
  9. alpha = case_when(
  10. .x > 3 && .id == "x" ~ 0.5,
  11. .y > -2.5 ~ 0.25,
  12. TRUE ~ 1
  13. ))
  14. aj_step3 <- aj_step2 %>%
  15. filter(alpha == 1) %>%
  16. mutate(frame = 3)
  17. aj_step4 <- aj_step2 %>%
  18. filter(alpha == 1) %>%
  19. mutate(frame = 4, .y = -1)
  20. aj <- bind_rows(
  21. initial_join_dfs,
  22. aj_step2,
  23. aj_step3,
  24. aj_step4
  25. ) %>%
  26. mutate(
  27. alpha = ifelse(is.na(alpha), 1, alpha),
  28. .obj = ifelse(value == 4, 0, .obj)
  29. ) %>%
  30. arrange(.obj, frame) %>%
  31. plot_data("anti_join(x, y)") %>%
  32. animate_plot(transition_length = c(2, 1, 2),
  33. state_length = c(1, 0, 0, 1))
  34. aj <- animate(aj)
  35. anim_save(here::here("images", "anti-join.gif"), aj)
  36. aj_g <- anti_join(x, y, by = "id") %>%
  37. proc_data() %>%
  38. mutate(.x = .x + 1.5) %>%
  39. plot_data_join("anti_join(x, y)")
  40. save_static_plot(aj_g, "anti-join")