i keep getting a error message the object of type ‘closure’ is not subsettable

Here is a sketch how I would do it (I haven’t included all inputs):

library(shiny)
library(DT)


ui <- fluidPage(
  
  # Application title
  titlePanel("Intervertebral Disc Degeneration Risk Prediction"),
  
  
  sidebarLayout(
    sidebarPanel(
      fluidRow(
        column(4,
               checkboxGroupInput("Smoke", "Smoking:",
                                  c("Yes" = "yes",
                                    "No" = "no"), selected = NULL)),
        column(4,
               checkboxGroupInput("Diabete", "Diabetes:",
                                  c("Yes" = "yes",
                                    "No" = "no"), selected = NULL)),
        column(4, 
               checkboxGroupInput("Athero", "Atherosclerosis:",
                                  c("Yes" = "yes",
                                    "No" = "no"), selected = NULL))),
      p(),
      fluidRow(
        column(4,
               checkboxGroupInput("Sickle", "Sickle Cell Anemia:",
                                  c("Yes" = "yes3",
                                    "No" = "no3"), selected = NULL)),
        column(4, 
               checkboxGroupInput("Other", "Other Infection:",
                                  c("Yes" = "yes4",
                                    "No" = "no4"), selected = NULL)),
        column(4,
               checkboxGroupInput("Spinal", "Spinal Cord Injury:",
                                  c("Yes" = "yes5",
                                    "No" = "no5"), selected = NULL))),
    ,
    
    # Show a plot of the generated distribution
    mainPanel(
      fluidRow(actionButton("button", "Click for Risk Prediction")),
      dataTableOutput("summary_table"),
      verbatimTextOutput('confusion_matrix')
    )
  )
)

# Define server logic required to draw a histogram
server <- function(input, output) {
  
  final_data <- eventReactive(input$button, {
    
    # create the df for the new test data
    test_data <- data.frame(Smoking = input$Smoke,
                            Diabetes = input$Diabete,
                            ...)
    
    # make the prediction
    predicted_value <- predict(super_model, newdata = test_data)
    
    # bind the data together and return it
    cbind(test_data, Risk = predicted_value)
  })
  
  output$summary_table <- renderDT(final_data()[, -which(colnames(final_data()) == "Risk")])
  
  output$confusion_matrix <- renderText({
    confusionMatrix(final_data())
  })
  
}

# Run the application 
shinyApp(ui = ui, server = server)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top