How to render a gganimate graph in html using rmarkdown::render(), without generating unwanted output

One workaround for this is to assign the animation to an object goo <- ggplot(... and write the animation to a file anim_save("goo.gif", goo) while suppressing results from the code chunk results = FALSE. Then render the gif in markdown immediately after the code chunk ![](goo.gif).

E.g.

---
title: "Testing gganimate with R Markdown"
output: html_document
---


```{r message = FALSE, warning = FALSE, results = FALSE}
library(ggplot2)
library(gganimate)
goo <- ggplot(mtcars, aes(factor(cyl), mpg)) + 
  geom_boxplot() + 
  # Here comes the gganimate code
  transition_states(
    gear,
    transition_length = 2,
    state_length = 1
  ) +
  enter_fade() + 
  exit_shrink() +
  ease_aes('sine-in-out')

anim_save("goo.gif", goo)
```


![](goo.gif)