I am trying to use a ggplot call inside of ddply as input to the animate package to create a time series world traffic animation. Here is my code;
library("ggmap")
library(maptools)
library(maps)
library(plyr)
......
#create map which we will then populate
mapWorld <- borders("world", colour="gray50", fill="gray50") # create a layer of borders
plots<-dlply(b, .(b$day), function(b) ggplot(b, aes(x=lon, y=lat, color=country,
group=country)) + mapWorld + geom_point(data=b, aes(x=lon, y=lat,
size=counts/100))+scale_size_identity(trans="sqrt")+guides(colour = guide_legend(override.aes
= list(size=3))))
library(animation)
#ani.options(interval=.05)
animation::saveVideo(plots, interval=0.5, video.name="world_animation.gif")
b is a data frame containing day eg. 01/01/2014,lon eg 73, lat e.g. 52, country e.g. US, counts e.g. 25.
However I keep getting the following error:
[image2 @ 0x7fd96c817000] Could find no file with path 'Rplot%d.png' and index in the range 0-4
Rplot%d.png: No such file or directory
Any suggestions?
Thanks!