Shiny: Filtering and displaying Dataframe from a eventReactive Input

I have the following codes.
I am trying to filter my dataset, based on the selected used input.
When user clicks update, I want to create a new dataset based on the filtered values.
I am unable to filter and show the output. Would anyone be able to help?

library(shiny)

hospitals <- read.csv("data/hospitals.csv")

ui <- fluidPage(

tabPanel("Distance from Hospital", p(),
         
         sidebarLayout(
           sidebarPanel(

             selectInput(inputId ="selected.state", label = "Choose a State", hospitals$State, selected = TRUE)
             actionButton(inputId = "update", label = "Update")

mainPanel(
tableOutput('filtered_table')
)

server <- function(input, output) {

filtered_by_state <- eventReactive(input$update, {
data.frame(subset(ED_hospitals, State == input$selected.state))
})
output$filtered_table <- renderDataTable({ filtered_by_state() })
}

Hi @squeeks2117 and welcome:)
I am not able to run your code on my computer. See this post on how to create a reproducable example

Apart from that, what is the error you are getting? Did you define the variable ED_hospitals?