DATA MINING
Desktop Survival Guide by Graham Williams |
|||||
Making an Animation |
Create 10 files of jpg
frames <- 10 for(i in 1:frames) { jpeg(sprintf("ani_%02d.jpg", i)) plot(1:10, 1:10, col=i) dev.off() } |
system("convert -delay 10 ani_??.jpg animation.gif") |
> ## > install.packages("animation") > library(animation) > # default animation in R: with slope changing > least.squares() > # animation in an HTML page > oopt = ani.options(ani.height = 450, ani.width = 600, outdir = tempdir(), nmax = 50, title = "Demonstration of Least Squares", description = "We want to find an estimate for the slope in 50 candidate slopes, so we just compute the RSS one by one. ") > ani.start() > par(mar = c(4, 4, 0.5, 0.1), mgp = c(2, 0.5, 0), tcl = -0.3) > least.squares() > ani.stop() > ani.options(oopt) |