In my data frame "df" I have a column with the name "currentABC" that has several unique values of type character. In my shiny model, I want to make it to where in the sidebar panel one of these unique values can be selected, and in my reactive table only the rows where "currentABC" match the input value selected are displayed in the table. Below is not all of my code, but a snippet that I think is where the problem lies. Currently I am getting an error message that says
"error in evaluating the argument 'condition' in selecting a method for function 'filter': error in evaluating the argument 'x' in selecting a method for function '%in%': object 'currentVOI' not found"
Thanks!
ui <- fluidPage(
titlePanel("title"),
sidebarLayout(
sidebarPanel(
selectInput(inputId = "CurrentABC",
label = "1. Select ABC",
choices = unique(df$currentVOI), selected = "123"),
server <- function(input, output, session) {
table <- reactive({
df %>% filter(currentABC == input$CurrentABC)
})
output$mytable <- renderTable({
table()
})
}
Here is an example with the iris dataset how you can do it: In the server part you can test two option (the first one is commented out) to test just comment out the other code in server part:
library(shiny)
library(dplyr)
# Define UI
ui <- fluidPage(
# Application title
titlePanel("Filter by Species"),
sidebarLayout(# Sidebar with a slider input
sidebarPanel(
selectInput("species", "Species",
choices = levels(iris$Species)
)
),
# Show a plot of the generated distribution
mainPanel(tableOutput("my_table")
)
)
)
server <- function(input, output) {
# output$my_table <- renderTable({
# subset(iris, Species == input$species)
# })
table <- reactive({
iris %>%
filter(Species == input$species)
})
output$my_table <- renderTable({
table()
})
}
shinyApp(ui, server)