0

I am trying to build a selector for a datatable object in my flexmarkdown sheet.

So this is my current (example) layout and I'm trying to build a reactive selector that takes the mineral type input on the left side and then re-renders the entire table to only select for "Rock Type = Type 1" in this case.

Full source @pastebin here: Link

My current selector:

```{r}
selectInput("input_type","Mineral Type:", data$`Rock Type`)

```

I'm been able to achieve this by doing the below but I'd also like to build in a selection for all/no groupings.

```{r}
dataInput <- reactive({
  subset(data,data$`Rock Type` == input$input_type)
  })

renderDataTable(dataInput())
```

Current Layout

sgdata
  • 2,543
  • 1
  • 19
  • 44

1 Answers1

1

You can add an All option to your selectInput, that you check in the reactive:

```{r}
selectInput("input_type","Mineral Type:", c("All", unique(data$`Rock Type`))
```

```{r}
dataInput <- reactive({
  if(input$input_type=="All")
    data
  else
    subset(data,`Rock Type` == input$input_type)
  })

renderDataTable(dataInput())
```
HubertL
  • 19,246
  • 3
  • 32
  • 51