-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathline_animation.R
More file actions
25 lines (21 loc) · 851 Bytes
/
line_animation.R
File metadata and controls
25 lines (21 loc) · 851 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
library(tidyverse)
library(gganimate)
## load RADPKO data
radpko <- read_csv('radpko_bases_cc.csv')
## create time-series animation
ts_gg <- radpko %>%
group_by(mission, date) %>% ## group by mission-date
summarize(personnel = sum(pko_deployed)) %>% # get total personnel deployed
ggplot(aes(x = date, y = personnel, color = mission)) + # setup ggplot
geom_line() + # lines
scale_color_discrete(name = 'Mission') + # legend title
labs(x = 'Date', y = 'Personnel') + # axis labels
ggtitle('Peacekeepers Deployed') + # title
theme_bw() + # simple theme
theme(panel.grid = element_blank(), # remove grid
panel.border = element_blank()) + # remove border
transition_reveal(date) # animation
## animate time-series at 5 FPS
anim <- animate(ts_gg, fps = 5)
## save gif
anim_save('personnel_timeseries.gif', animation = anim)