我正嘗試在Windows 7計算機的RStudio 0.98.1102中使用R 3.1.3的'animate'包。我已經安裝了ImageMagick,如果我寫下面幾行,我會得到一個動畫gif文件。R中的'動畫'包將狀態保存爲GIF 127
library(animation)
ani.options('C:/Program Files/ImageMagick-7.0.4-Q16/convert.exe')
png(file="example%02d.png",width=200, height=200)
for(i in c(10:1,"GO!")){
plot.new()
text(.5,.5,i,cex=6)
}
dev.off()
system("magick -delay 80 *.png example_1.gif")
到目前爲止這麼好。但是當我嘗試使用gganimate包時,我遇到了問題。我剛纔複製從動畫包GitHub的頁面下面幾行:
library(gapminder)
library(ggplot2)
theme_set(theme_bw())
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color =
continent, frame = year)) +
geom_point() +
scale_x_log10()
library(gganimate)
gganimate(p)
被執行的最後一個行之後,我收到以下錯誤:
現在,我寫了下面的命令,然後重新運行得到一個類似的錯誤消息,並沒有gif文件產生:
ani.options(convert = shQuote('C:/Program Files/ImageMagick-7.0.4-
Q16/magick.exe'))
gganimate(p)
現在,如果我寫下面的線,我得到錯誤消息,但會生成一個動畫gif文件。
ani.options(convert = shQuote('C:/Program Files/ImageMagick-7.0.4-
Q16/magick.exe'))
gganimate(p, "output.gif")
動畫不RStudio顯示,我必須尋找到新的gif文件保存在工作目錄的位置。
我不明白爲什麼會發生這種情況,以及如何使用gganimate()生成.gif(內部RStudio),而不會產生任何錯誤消息。我將非常感謝您對上述問題的反饋,建議和解決方案。
是的,我已經安裝ImageMagick和工程。我已經使用過系統(「magick -delay 80 * .png example_1.gif」)來生成一個gif文件。 –