forked from R-tutorials/tidy-animated-verbs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
union_all.R
23 lines (18 loc) · 821 Bytes
/
union_all.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
source(here::here("R/00_base_set.R"))
ua <- bind_rows(
initial_set_dfs,
initial_set_dfs %>% mutate(frame = 2, .y = ifelse(.id == "y", .y - 3, .y)), # fly y down
proc_data_set(x, "ux") %>% mutate(frame = 3, .x = .x + 1.5), # merge
proc_data_set(y, "uy") %>% mutate(frame = 3, .x = .x + 1.5, .y = .y - 3), # un-merge
initial_set_dfs %>% mutate(frame = 4, .y = ifelse(.id == "y", .y - 3, .y)) # fly y up
) %>%
arrange(desc(frame)) %>%
plot_data_set("union_all(x, y)", ylims = ylim(-5.5, -0.5)) +
transition_states(frame, 1, c(1, 0, 1, 0))
ua <- animate(ua)
anim_save(here::here("images", "union-all.gif"), ua)
ua_g <- union_all(x, y) %>%
proc_data_set() %>%
mutate(.x = .x + 1.5) %>%
plot_data_set("union_all(x, y)", ylims = ylim(-5.5, -0.5))
save_static_plot(ua_g, "union-all")