thomasp85 / gganimate

A Grammar of Animated Graphics
https://gganimate.com
Other
1.94k stars 310 forks source link

revealjs_presentation saved animation folder #187

Open rdinter opened 6 years ago

rdinter commented 6 years ago

With a file structure of:

Where gg_issue.Rmd reads in gg_chunk.R as a chunk and contains an animation from gganimate, the figure that is animated is saved in a different location than a generic plot. The contents of gg_issue.Rmd is:

---
title: "GG Issues"
output:
  revealjs::revealjs_presentation:
        keep_md: true
        self_contained: true
---

```{r, include=FALSE}
library("knitr")
opts_knit$set(root.dir = normalizePath(".."))
read_chunk("gg_chunk.R")

Title




And the gg_chunk.R file contains:

---- start --------------------------------------------------------------

library("gganimate")

---- generic ------------------------------------------------------------

ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot()

---- animate-cars -------------------------------------------------------

ggplot(mtcars, aes(factor(cyl), mpg)) + geom_boxplot() + transition_manual(gear)



 The specific error is:

`pandoc: Could not fetch gg_issue_files/figure-revealjs/animate-cars-1.gif
gg_issue_files/figure-revealjs/animate-cars-1.gif: openBinaryFile: does not exist (No such file or directory)
Error: pandoc document conversion failed with error 67
Execution halted`

What appears to be happening is that the animation is saved in a folder of `gg_issue_files/figure-revealjs/` is created at the same level as `folder` instead of within `folder`. There is also a `gg_issue_files/figure-revealjs/` within `folder` which contains the generic plot. The .Rmd will work fine without the animation.

This particular issue only occurs when the .Rmd file is within a folder (and the `opts_knit$set(root.dir = normalizePath(".."))` is no longer present).
thomasp85 commented 6 years ago

@yihui is this a gganimate issue? I don't think I can do more, filenaming-wise, in knitr_print than I already do..?