已经安装了ImageMagick和devtools包
在cmd窗口测试ImageMagick可以将png图转换为gif图,测试语句:
+++++++++
magick convert *.png -delay 3 -loop 0 binom.gif
++++++++
安装gganimate,使用安装语句如下:
++++++++++++++++++++++++++++
install.packages("devtools")
devtools::install_github("dgrtwo/gganimate",force = T)
++++++++++++++++++++++++++++
安装提示
+++++++++++++++++++++
Downloading GitHub repo dgrtwo/gganimate@master
These packages have more recent versions available.
Which would you like to update?
1: All
2: CRAN packages only
3: None
4: gtable (0.2.0 -> 0.3.0) [CRAN]
5: lazyeval (0.2.1 -> 0.2.2) [CRAN]
6: R6 (2.3.0 -> 2.4.0) [CRAN]
7: Rcpp (1.0.0 -> 1.0.1) [CRAN]
8: rlang (0.3.1 -> 0.3.4) [CRAN]
9: stringi (1.2.4 -> 1.4.3) [CRAN]
10: stringr (1.3.1 -> 1.4.0) [CRAN]
11: tibble (2.0.1 -> 2.1.1) [CRAN]
Enter one or more numbers separated by spaces, or an empty line to cancel
1:
++++++++++++++++++++++++++++++++++++
然后选择1 ,就是全部安装
安装问题提示:
+++++++++++++
package ‘gtable’ successfully unpacked and MD5 sums checked
package ‘lazyeval’ successfully unpacked and MD5 sums checked
Error: (converted from warning) cannot remove prior installation of package ‘lazyeval
+++++++++++++
然后想使用gganimate
语句如下:
++++++++++++++++++++++++++++++++++++
library(gganimate)
library(ggplot2)
aq<-airquality
#按年-月-日整理日期
aq$date <- as.Date(paste(1973,aq$Month,aq$Day,sep="-"))
#每一幅图按Month生成
p<-ggplot(aq,aes(date,Temp,frame=Month,cumulative=T))+geom_line()
#显示ggplot2对象p的动画,并保存到指定名称的文件
gganimate(p,filename="aq_output.gif",title_frame=F)
+++++++++++++++++++++++++++++++++++++
提示错误:
+++++++++++++++++++++++
Error: It appears that you are trying to use the old API, which has been deprecated.
Please update your code to the new API or install the old version of gganimate
from https://github.com/thomasp85/gganimate/releases/tag/v0.1.1
+++++++++++++++++++++++