Animated GIF wont play on Shiny app




I am in the process of making a Shiny App that takes some user input, a data set, and then plays a gif on the data points. I am relatively new to R and a total Shiny novice.

The file input stuff is working fine, but I have issues with playing (and eventually) downloading the GIF when the app is published.

What surprises me is that the gif plays out perfect in the review pane of RStudio and also when I open in browser. Error messages and problems creep in when I publish the app and try to use the “real” online version.

Below I have posted a generic representation of my problem, abstracting from file inputs etc. The data set used here is simply data1, created in the beginning of the server section.

My goal is to make an animated gif in this plot, sequentally playing the different (x,y)-values of data1. As abovementioned this works perfectly in review and in browser - it becomes a problem when the app is published.

Where plot_3 is supposed to be I am met with a message in red saying:

“Error. An error has occurred. Check your logs or contact the app author for clarification.”

Do anyone have suggestions for how to play a GIF in Shiny? (i.e., a GIF based on data set that is made or loaded in the server function as well).

I have tried another approach as well, basically copying the tip found here.

Similar problems arose. Everything worked fine until using the “real” online version. There was no error message, however, there was just no gif for download.




ui <- fluidPage(

server <- function(input, output) {
    x <- c(1,2,3,4)
    y <- c(2,4,5,10)
    data_try <- data.frame(x,y)
  ##Try renderimage
  output$plot_3 <- renderImage({
    p <- ggplot(data1(),aes(x=x,y=y,type="p",frame=x))+geom_point(color="red",size=3)
    list(src ="outfile.gif",
         contentType = 'image/gif',
         width = 400,
         height = 300,
         alt = "This is alternate text"
    )},deleteFile = TRUE)

shinyApp(ui = ui, server = server)