我有一个州每个县的每周数据。我想创建一个动画,每周循环显示绘制到地图上的数据,颜色表示强度和/或前一周的变化。
library(ggplot2); library(animation); library(maps); library(plyr)
county <- map_data("county")
wy <- county[county$region =="wyoming",]
l = length((wy$subregion))
#Add random variales
wy <- mutate(wy, a = runif(length(region)),
b = runif(length(region)),
c= runif(length(region)))
test <- function(j){
ggplot(wy, aes(long, lat, group = group))+
geom_path() +
geom_polygon(aes_string(fill=j))
}
test("c")
test("b")
v = c("a","b","c"))
oopt <- animation::ani.options(interval = 0.1)
FUN2 <- function() {
lapply(v, function(i) {
test(i)
animation::ani.pause()
})
}
FUN2()
saveHTML(FUN2(), autoplay = FALSE, loop = FALSE, verbose = FALSE, outdir = "images/animate/new",
single.opts = "'controls': ['first', 'previous', 'play', 'next', 'last', 'loop', 'speed'], 'delayMin': 0")
最后一个函数调用有什么问题?