0

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?

Cdhabhai
  • 3
  • 3

1 Answers1

3

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)

enter image description here

Pork Chop
  • 28,528
  • 5
  • 63
  • 77
  • 1
    Thankyou! this works perfect. I have one more roadblock that I have a check of "isTruthy" to show all data if none of the filter is selected, as i have multiple filters.The " " value is not getting through this check.Is there any workaround that you know,it will really help a lot. – Cdhabhai Jun 08 '20 at 13:56