-
Notifications
You must be signed in to change notification settings - Fork 315
Closed
Labels
Description
first reported at quarto-dev/quarto-cli#6643
Same example as #484 but trying to override global dev by in-chunk dev, while using animate()
---
title: "Label shouldn't be named"
output:
html_document:
dev: svg
---
```{r}
library(gganimate)
```
```{r, dev = "png"}
p <- ggplot(mtcars, aes(factor(cyl), mpg)) +
geom_boxplot() +
transition_states(gear)
animate(p)
```Traceback is
Quitting from lines 13-17 [unnamed-chunk-2] (test.Rmd)
Error in `device()`:
! arguments inutilisés (units = "in", res = 96)
Backtrace:
1. gganimate::animate(p)
2. gganimate:::animate.gganim(p)
4. gganimate (local) `<fn>`(...)
Exécution arrêtée
knit_print method is not used in this case, and animate try to deal with knitr context itself. Though it is using opts_chunk$get()
Line 213 in 7cd46dc
| chunk_args <- if (is_knitting()) get_knitr_options(knitr::opts_chunk$get(), unlist = FALSE) else list(dev_args = list()) |
This means only global option will be used. Hence same error as in #484 because dev: svg from YAML field is used, setting device to svg()
opts_current$get() should be used to get options including modify ones by current chunk level options
---
title: "Label shouldn't be named"
output:
html_document:
dev: svg
---
```{r}
library(gganimate)
```
```{r, dev = "png"}
knitr::opts_chunk$get("dev")
knitr::opts_current$get("dev")
```I believe this should fix it
