Using two dynamic inputs to update a table

Using the iris data set, I am trying to produce a table in shiny that can be adapted based on species (by selection from a drop down), and the specimen id using the slider. I am able to get the dropdown menu to work, but can't get the slider to work. How do I make it so that both user inputs change the table?

# Load Libraries

library(shiny)
library(tidyverse)
library(tidytext)
library(glue)
library(plotly)


# Read Data 

iris <- read_rds("iris.rds")

iris

ui <- fluidPage(
  titlePanel("Flower dimensions by species"),
  sidebarLayout(
    sidebarPanel(
      selectInput(
        inputId = "species",
        label = "Select species",
        choices = c("setosa", "versicolor", "virginica"),
        multiple = TRUE
      ),
      sliderInput(
        inputId = "specimen_selection",
        label = "Select specimen range",
        min = min(iris$id, na.rm = TRUE),
        max = max(iris$id, na.rm = TRUE),
        value = 2
      )),
    mainPanel(
      p("Using the selection box, you can sort through the iris specimens based on Species"),
      dataTableOutput(outputId = ("Specimen_details")
    )
  )))

server <- function(input, output) {
  output$Specimen_details <- renderDataTable({dplyr::filter(
    iris, species %in% input$species)
  })

}

shinyApp(ui = ui, server = server)



Read more here: https://stackoverflow.com/questions/67944488/using-two-dynamic-inputs-to-update-a-table

Content Attribution

This content was originally published by avan at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: