I want to display my animated bar plot in R shiny web app. I am getting my animated plot in the Rstudio viewer pane but unfortunately, it is not working in app
CODE:
# LIBRARIES
library(ggplot2)
library(shiny)
library(gganimate)
# LOADING CSV
undergradDATA <- read.csv(file="1-10 Undergraduates.csv", head=TRUE, sep=",")
# UI
ui <- fluidPage (
mainPanel(
plotOutput("myplot")
)
)
# SERVER
server <- function(input, output) {
output$plot <- renderPlot({
undergrad_plot <- ggplot(data=undergradDATA , aes(x=HEI, y=Undergrad), height = 461, width = 644) +
geom_bar(stat='identity', fill="darkolivegreen3", colour="white")
undergrad_plot + ggtitle("Ranking of Top 10 HEI's w.r.t Undergraduates") +
theme(
plot.title = element_text(hjust = 0.5,
colour = "darkolivegreen",
size = 17,
family = "courier"
) )
undergrad_plot + transition_states(Undergrad, wrap = FALSE) +
shadow_mark() +
enter_grow() +
enter_fade()
})
}
# RUNNING APP
shinyApp(UI, server)