0

I have 4 png images that I want to use to create a little animation. I would like to be able to set the speed between the images, and to have play/pause, back, forward buttons. Is this possible?

I found the animation package, but I don't think is possible to use png instead of R graphs to create the animation.

The goal is to use this animation in a R shiny presentation. So, shiny could be an option.

Thanks!


My solution right now is to have many slides:

## figures/Timeline {.flexbox .vcenter}

![figures/Timeline 1](figures/Timeline/1.png)

## figures/Timeline {.flexbox .vcenter}

![figures/Timeline 2](figures/Timeline/2.png)
Ignacio
  • 7,646
  • 16
  • 60
  • 113
  • 1
    I think you want ImageMagick http://tolstoy.newcastle.edu.au/R/e2/help/06/09/1365.html as referenced in this SO: http://stackoverflow.com/questions/1384403/making-animated-gifs-using-r – sunny Jul 13 '15 at 15:46

1 Answers1

0

This is a solution using shiny:

## Test

```{r, echo=FALSE, message=F}

server <- shinyServer(function(input, output, session) {
  # Send a pre-rendered image, and don't delete the image after sending it
  output$preImage <- renderImage({
  filename <- normalizePath(file.path('./figures/vertchart',
  paste(input$n, '.png', sep = '')))
  # Return a list containing the filename and alt text
  list(src = filename,
  alt = paste("Image number", input$n))

  }, deleteFile = FALSE)
  })



  ui <-  shinyUI(
  fluidPage(
  absolutePanel(
  top = 0, right = 20, width = 200,
  draggable = TRUE,
  wellPanel(
  sliderInput(
  "n", "", min = 1, max = 5, value = 1, animate = animationOptions(interval =
  1200)
  )
  ),
  style = "opacity: 0.99"
  ),
  imageOutput("preImage", width = "100%"
  )
))

shinyApp(ui = ui, server = server)
```
Ignacio
  • 7,646
  • 16
  • 60
  • 113