# NOT RUN {
#make a video with animation package
# }
# NOT RUN {
require(animation)
fun <- function(){
y <- sin(1:50)
x <- 1:50
for(i in 1:50) {
plot(x[i],y[i],col="red",xlim=c(0,50),ylim=range(y))
animation::ani.pause()
}
}
animation::saveVideo(fun(),video.name=paste0(tempdir(),"/wave.mp4"),interval = 0.2)
#create directory in which to store images
dir.create(paste0(tempdir(),"/images"))
vid.to.images(vid.path=paste0(tempdir(),"/wave.mp4"),
out.dir= paste0(tempdir(),"/images"),qual=100)
#see the images in the "images" subdirectory
list.files( paste0(tempdir(),"/images"))
#clean up
unlink(paste0(tempdir(),"/images"),recursive=TRUE)
# }
Run the code above in your browser using DataLab