Description Usage Arguments Value Examples
View source: R/gganimate_helpers.R
To be used with transition_reveal()
1 | split_track(df, grouping_var, tracked_along, ..., tracked_groups = NULL)
|
df |
data frame |
grouping_var |
column of the grouping variable used to split the data |
tracked_along |
column of the tracking dimension to be passed into |
... |
specification for the tracking window passed to dplyr::filter() |
tracked_groups |
levels of the grouping_var to be tracked. Defaults to value NULL, which tracks all groups. |
a data frame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ## Not run:
set.seed(123)
plot_df <- tibble(
a = cumsum(runif(100, -1, 1)),
b = cumsum(runif(100, -1.5, 1.5)),
c = cumsum(runif(100, -2, 2)),
d = cumsum(runif(100, -2.5, 2.5))
) %>% pivot_longer(a:d) %>%
group_by(name) %>%
mutate(reveal_time = row_number(), x = row_number()) %>%
ungroup()
anim <- plot_df %>%
split_track(grouping_var = name, tracked_along = reveal_time, x > 74) %>%
ggplot(aes(x, value, color = name)) +
geom_line(size = 1) +
transition_reveal(reveal_time) +
theme_classic()
animate(anim, width = 5, height = 3, units = "in", res = 150)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.