-1

Working on building a shiny app where I've few options and I wish to create a further option which provides for all. For example,

Option A Option B Option C

Now A, B, C are particular values of a variable. Now I wish to see details when another option "Option All" is selected and that's the combined of (A, B, C). Please help.

drsb24
  • 1
  • Please consider referring to [this discussion](http://stackoverflow.com/q/5963269/1655567) and making your post reproducible. – Konrad Mar 31 '17 at 07:03

1 Answers1

0

Here You have the solution for Your question of radioButtons with the option All:

library(shiny)
library(DT)

value <- c(1,2,3)
variable <- c("A","B","C")

data <- data.frame(value, variable)

ui= fluidPage(
    radioButtons("choice","Choose:", choices = c("A","B","C","All"), selected = "All"),
      dataTableOutput("tab")
    )

server= function(input, output,session) {

  data_reactive <- reactive({
    if(input$choice =="All"){
      data <- data
    }
    else{
      data <- data[data$variable %in% input$choice, ]
    }
    data
  })

  output$tab <- DT::renderDataTable({
    datatable(data_reactive())})


}

shinyApp(ui, server)

and for the future as @Konrad said, it would be good if You post reproducible example and more clearly define the problem.

Mal_a
  • 3,670
  • 1
  • 27
  • 60