输入更改时,闪亮的情节不会更新

Shiny plot not updating when inputs are changed

library(ggplot2)
library(shiny)
library(lubridate)

movies = read.csv("/Users/michael/Desktop/stat 479 proj data/marvel_clean.csv")
reviews = read.csv("/Users/michael/Desktop/stat 479 proj data/marvel_reviews_clean.csv")

reviews = reviews %>% slice(-(2:4)) %>% rename(Title = Film)

J.dat = left_join(movies,reviews, by = "Title")

J.dat = J.dat %>% mutate(date = substr(ReleaseDateUS, 1, 4)) %>% select(-ReleaseDateUS)
J.dat$date = as.numeric(J.dat$date)
J.dat = J.dat  %>% 
  mutate_all(~replace(., is.na(.), 0))  %>%
  select(-CinemaScore, -CinemaScore.1)

Distributor <- pull(J.dat, Distributor) %>%
  unique() %>%
  na.omit()



barplot <- function(df) {
  ggplot(df, aes(x=Title, y=Budget, fill=Budget, col = Distributor)) +
    geom_bar(width = 0.75,  stat = "identity", colour = "red", size = selected, alpha = selected) +
coord_flip()
}
    


### definition of app
ui <- fluidPage(
  titlePanel("Marvel Movies"),
  selectInput("Distributor", "Studio", Distributor, multiple = TRUE),
  sliderInput("year", "Year", min = min(J.dat$date), max = max(J.dat$date), c(1986, 2021)),
  sliderInput("rating", "Rating", min = min(J.dat$Metacritic), max = max(J.dat$Metacritic), c(0, 88), sep = ""),
  plotOutput("Marvel_Bar")
)


server <- function(input, output) {
  movies_subset <- reactive({
   J.dat %>%
      mutate(selected = (
       (Distributor %in% input$studio) 
        (Metacritic >= input$rating[1]) &
        (Metacritic <= input$rating[2]) &
      (date >= input$year[1]) &
         (date <= input$year[2]) 
      ))
  })
  
  output$Marvel_Bar <- renderPlot({
    barplot(movies_subset())
  })
}

app <- shinyApp(ui, server)




我 运行 遇到了一个问题,当我的任何输入发生变化时,我的情节都没有更新。我认为问题可能出在我的反应函数中的某个地方,但我一直无法弄清楚(闪亮仍然很新)。闪亮的应用程序运行它只是不会更新。

我正在使用的数据可以在这里下载: https://www.kaggle.com/minisam/marvel-movie-dataset?select=marvel.csv

  movies_subset <- reactive({
   J.dat %>% filter(
      (Distributor %in% input$studio) &
      (Metacritic >= input$rating[1]) &
      (Metacritic <= input$rating[2]) &
      (date >= input$year[1]) &
      (date <= input$year[2]) 
      )
  })

服务器功能需要更改为此,现在可以使用了