簡體   English   中英

Rmarkdown 渲染到使用 gganimate 的 pdf

[英]Rmarkdown rendering to a pdf that uses gganimate

我正在運行主要的gganimate示例,它將動畫 plot 渲染到 pdf 文檔中。

---
title: "PDF Animation Test"
output:
  html_document:
  pdf_document: default
header-includes: \usepackage{animate}
---
  
`gganimate` now supports animations inside PDF documents. This feature is only 
viewable with Acrobat Reader, however. Remember to include 
`\usepackage{animate}` in the preamble and set `fig.show='animate'` in the chunk
options. Further, the framerate is governed by `interval`rather than any 
`gganimate` settings:
  
```{r, fig.show='animate', interval=1/10}
library(gganimate)
ggplot(airquality, aes(Day, Temp, group = Month)) + 
  geom_line() + 
  transition_reveal(Month)
```   

我收到以下錯誤:

label: unnamed-chunk-1 (with options) 
List of 2
 $ fig.show: chr "animate"
 $ interval: language 1/10



processing file: pdf.Rmd
executing: ffmpeg -y -r 10 -i pdf_files/figure-html/unnamed-chunk-1-%d.gif -b:v 1M -crf 10 pdf_files/figure-html/unnamed-chunk-1.webm

/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS pdf.utf8.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output pdf.html --email-obfuscation none --self-contained --standalone --section-divs --template /home/manolo/R/x86_64-pc-linux-gnu-library/4.0/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --variable 'theme:bootstrap' --include-in-header /tmp/Rtmp8AGRpp/rmarkdown-str39681ce56ba1.html --mathjax --variable 'mathjax-url:https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --lua-filter /home/manolo/R/x86_64-pc-linux-gnu-library/4.0/rmarkdown/rmd/lua/pagebreak.lua --lua-filter /home/manolo/R/x86_64-pc-linux-gnu-library/4.0/rmarkdown/rmd/lua/latex-div.lua 
ffmpeg version N-98534-g5eb4405 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/home/manolo/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/manolo/ffmpeg_build/include --extra-ldflags=-L/home/manolo/ffmpeg_build/lib --extra-libs='-lpthread -lm' --bindir=/home/manolo/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
  libavutil      56. 56.100 / 56. 56.100
  libavcodec     58. 97.100 / 58. 97.100
  libavformat    58. 49.100 / 58. 49.100
  libavdevice    58. 11.101 / 58. 11.101
  libavfilter     7. 87.100 /  7. 87.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
pdf_files/figure-html/unnamed-chunk-1-%d.gif: No such file or directory
output file: pdf.knit.md

File pdf_files/figure-html/unnamed-chunk-1.webm not found in resource path
Error: pandoc document conversion failed with error 99
Execution halted

我的 sessionInfo() 是:

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0

locale:
 [1] LC_CTYPE=en_CA.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_CA.UTF-8        LC_COLLATE=en_CA.UTF-8    
 [5] LC_MONETARY=en_CA.UTF-8    LC_MESSAGES=en_CA.UTF-8   
 [7] LC_PAPER=en_CA.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] rstudioapi_0.11   magrittr_1.5      knitr_1.29.3      usethis_1.6.1    
 [5] devtools_2.3.0    pkgload_1.1.0     R6_2.4.1          rlang_0.4.7      
 [9] fansi_0.4.1       tools_4.0.2       pkgbuild_1.1.0    xfun_0.15        
[13] sessioninfo_1.1.1 cli_2.0.2         withr_2.2.0       remotes_2.1.1    
[17] htmltools_0.5.0   ellipsis_0.3.1    yaml_2.2.1        assertthat_0.2.1 
[21] digest_0.6.25     rprojroot_1.3-2   crayon_1.3.4      processx_3.4.3   
[25] callr_3.4.3       fs_1.4.1          ps_1.3.3          curl_4.3         
[29] testthat_2.3.2    memoise_1.1.0     glue_1.4.1        evaluate_0.14    
[33] rmarkdown_2.3     compiler_4.0.2    desc_1.2.0        backports_1.1.8  
[37] prettyunits_1.1.1

########更新########

我也試過:

library(knitr)
knit('pdf.Rmd') 

它創建了一個名為“figure”的文件夾,其中包含“unnamed-chunk-1-1.gif”,我對其進行了修改以創建文件夾:

  • pdf_files/figure-html/unnamed-chunk-1-%d.gif
  • pdf_files/figure-html/unnamed-chunk-1.webm

然后我編織了我的文件,但我得到了一個 .html 文檔,而不是我期待的 pdf 文檔。

我使用以下方法安裝了tinitex:

install.packages('tinytex')
tynitex::install_tinytex()

這解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM