0

Pretty simple question, but I can't figure out how to save the actual animated map so that I can send it to people. I've created an animated map in R using ggplot2, but I can't seem to just save it as a gif or jpg or whatever I'm supposed to save it as in order to send it to people (i.e. my boss).

How can I do this? It seems like it should be very easy, but I'm having no luck.

File_I_Used <- file.choose(new = TRUE)
origAddress <- read.csv(File_I_Used, header = TRUE, stringsAsFactors = FALSE)

head(origAddress)

Closing.Date Year   Qtr          lon      lat
1       2004/9 2004 4-Mar    -93.26686 44.96116
2       2004/9 2004 4-Mar     -93.26686 44.96116
3      2004/10 2004 4-Apr    -93.26686 44.96116
4      2004/11 2004 4-Apr     -93.27559 44.93343
5      2004/11 2004 4-Apr   -93.25080 44.95893
6      2004/11 2004 4-Apr    -93.25087 44.95885

City <- ggmap(get_googlemap(center = c(lon = -93.2638397, lat = 44.979969),
                                   zoom = 12, scale = 2,
                                   maptype = "roadmap",
                                   color = "color"))
City

Properties <- data.frame(origAddress)
Properties

Final_View <- City + theme(legend.position = "none", axis.ticks.x = element_blank(), axis.ticks.y = element_blank(),
                                  axis.text.x = element_blank(), axis.text.y = element_blank()) + 
  geom_point(aes(x = lon, y = lat, color = "Year"), data = Properties, size = 2) +
  transition_states(Year, transition_length = 0) +
  shadow_mark(past = TRUE) +
  labs(title = "My Title")
Final_View
walyba
  • 25
  • 5
  • What functions did you use to make the animated map? – MrFlick Oct 22 '19 at 17:31
  • I used ggmap and get_googlemap to make the map and geom_point to plot the points. – walyba Oct 22 '19 at 17:35
  • But none of those commands would make it animated. Are you using `ggnimate? or something? It's easier to help you if you include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input that can be used to test and verify possible solutions. – MrFlick Oct 22 '19 at 17:42
  • Sorry, yes I am using gganimate. I've edited my post to include my code along with the firs 6 rows of data from the file I used. I have deleted the actual addresses from the data set since it's personal info, but if that is necessary please just let me know. – walyba Oct 22 '19 at 17:52
  • I think I should add that when I try to use gganimate() it brings back an error that I'm trying to use the old API. I don't know what this means considering I only just started working in R the last few weeks, so I'm confused on how I could've downloaded an old version of something. How can I "update [my] code to the new API"? – walyba Oct 22 '19 at 17:57
  • You should use the [anim_save](https://www.rdocumentation.org/packages/gganimate/versions/1.0.3/topics/anim_save) function to save an image. That package has undergone a lot of changes over time. That message means you are using functions from the "old" style of calling the functions. They are still included for backwards compatibility but are not how the author suggests making plots with the package. – MrFlick Oct 22 '19 at 18:00
  • I figured it out...before your most recent answer I found [this](https://stackoverflow.com/questions/51440496/using-gganimate-to-export-gif) which is why I asked about animate. But I hadn't yet scrolled all the way down and read all the comments. The very last comment says basically what you said, and it worked! So thank you very much, this has been very educational. – walyba Oct 22 '19 at 18:19

0 Answers0