0

I have been trying to plot an animation which will show the number of refugees over the years. The code runs without issues, but it won't show the output animation. Could someone please tell me what I am doing wrong?

animation <- refugees_clean %>% 
ggplot( aes(x=year, y=number, group= origin_region, color=origin_region)) +
geom_line() +
geom_point() +
scale_color_discrete() +
ggtitle("Refugee numbers over the years") +
theme_dark() +
ylab("Number of refugees") +
transition_reveal(year)
animation
dput(head(refugees_clean))
structure(list(origin_country = c("Afghanistan", "Angola", "Armenia", 
"Azerbaijan", "Belarus", "Bhutan"), iso3 = c("AFG", "AGO", "ARM", 
"AZE", "BLR", "BTN"), origin_region = c("South Asia", "Sub-Saharan 
Africa", 
"Europe & Central Asia", "Europe & Central Asia", "Europe & Central 
Asia", 
"South Asia"), origin_continent = c("Asia", "Africa", "Asia", 
"Asia", "Europe", "Asia"), year = c(2006, 2006, 2006, 2006, 2006, 
 2006), number = c(651, 13, 87, 77, 350, 3), year_date = 
 structure(c(13149, 
 13149, 13149, 13149, 13149, 13149), class = "Date")), row.names = 
 c(NA, 
 -6L), class = c("tbl_df", "tbl", "data.frame"))
  • 1
    Can you share data to make this reproducible? Could you edit your question with `dput(head(refugees_clean))` for example? – Ben Nov 04 '20 at 03:33
  • 1
    Can you describe what your code does currently? What output do you get? Are you getting a list of image filenames, for example? – Ben Nov 04 '20 at 03:46
  • The code output produces a series of .png files and I don't know where these are being saved either. – Alexander Fos Nov 05 '20 at 15:32
  • I believe you need to use `animate(animation)` (https://www.rdocumentation.org/packages/gganimate/versions/1.0.6/topics/animate), and I would save it directly to a .gif with `anim_save` (https://www.rdocumentation.org/packages/gganimate/versions/1.0.6/topics/anim_save) – DS_UNI Nov 05 '20 at 15:40
  • Also take a look at: https://stackoverflow.com/questions/58991580/gganimate-returns-png-files-but-no-animated-object and https://stackoverflow.com/questions/59664377/gganimate-plot-not-showing-and-saving-bunch-of-pngs – Ben Nov 05 '20 at 15:57

0 Answers0