How can I build Shiny applications with Animation

2019-02-20 05:26发布

问题:

I am trying to build a shiny app to build interactive animations with R. I currently have a function that can build gifs/other output options using the Animation package(http://cran.r-project.org/package=animation) that loops through a series of ggplots(by date). And also a shiny app that can show a single ggplot based on the selected date.I want to build a shiny app that refreshes an animation based on a selected date range.

Are there examples of code that uses maybe saveHTML with UIoutput in Shiny? Would this be possible?

reset animation in Shiny R Studio shows someone trying to build an animation within Shiny. https://gist.github.com/yihui/5899181 is example of integrating a saveGIF function into a shiny app, but that is through a download.

Alternative suggestions/packages I could look at to approach this problem in R not necessarily using Animation and/or Shiny would also be appreciated.

回答1:

I suggest using the googleVis package --> the tool, gvisMotionchart. It's really simple to work with, just make sure your data is numeric or time oriented in some way and also have some character/categorical variable to plot as circles. Best of all is that all animation tools are ALREADY included inside the motion chart.

If you want details how to create this, here is a model example of how to detailed in this thread.

Chart not generated in R shiny when run locally using googleVis

Here's a screenshot of an example of one I've created to visualize chess data.

googlevis example