So, I've created the following reprex, but hopefully someone can explain it to me. Basically I have 2 inputs, one to select a row from a data frame (Player), and one to filter the data frame (Team). I want to display the selected row in table format, bur only if the row has been selected so as not to only display the column headers. If I filter then select a row, or just select a row, it works just fine. If at that point I change the filter input (Team) , the player data is cleared, but the table is still displayed with no data, so obviously req(player()$Name) is staying true forever once it is satisfied once. Any ideas how to "clear" or "reset" that?
library(reprex)
ui <- shinyUI(fluidPage(
selectizeInput("team","Team",c(Team = " ",Blue = "B", Red = "R")),
selectizeInput("player","Player",c(Player='')),
tableOutput("player_info"),
br(),
verbatimTextOutput("playah")
))
server <- shinyServer(function(input, output,session) {
observe({
req(player()$Name)
output$player_info <<- renderTable(player())
})
output$playah <-renderPrint(player())
player_df <- tibble(Name = c("Abe","Bob"), Team = c("B","R"))
player_list <- reactive({
if(input$team == " "){
player_df %>% .$Name
}else{
player_df %>% filter(Team == input$team) %>% .$Name
}})
observe({ player_list
updateSelectizeInput(session,"player",choices = c(' '='',player_list()))
})
player <- reactive(player_df %>% filter(Name == input$player))
})
shinyApp(ui = ui, server = server)