I am developing a shiny application which has a selectInput filter whose choices are coming from a dataframe of NAMES. This selectinput allows to filter rows in rhandsontable on the basis of names. At present the selectinput doesn't show "" choice where NAME is empty i.e "" and only show available NAMES. I want to filter rows in table which don't have any names (i.e NAMES=="") via selectinput. Could you please help on how to do it?
May I suggest you go with shinyWidgets
package, I know that selectInput
will not allow you to do a null
show:
library(shiny)
library(shinyWidgets)
data <- head(mtcars)
data$NAMES <- data$mpg
data$NAMES[c(1,3)] <- ""
ui <- fluidPage(
pickerInput(
inputId = "NAMES",
label = "NAMES",
choices = unique(data$NAMES),
selected = "",
multiple = TRUE,
options = pickerOptions(maxOptions = 1)
),
tableOutput("table")
)
server <- function(input, output,session) {
mydata <- eventReactive(input$NAMES,{
data[data$NAMES %in% input$NAMES,]
})
output$table <- renderTable({
mydata()
})
}
shinyApp(ui = ui, server = server)