在 flexmarkdown 中创建选择性数据表

Selective datatable creation within flexmarkdown

我正在尝试在我的 flexmarkdown sheet.

中为 datatable 对象构建一个 selector

所以这是我当前的(示例)布局,我正在尝试构建一个反应式 selector 接受左侧的矿物类型输入,然后重新渲染 在这种情况下,整个 table 到 "Rock Type = Type 1" 的 select。

完整源代码@pastebin 在这里:Link

我目前的select或:

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

```

我可以通过执行以下操作实现此目的,但我还想为 all/no 分组构建 selection。

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

renderDataTable(dataInput())
```

您可以向您的 selectInput 添加一个 All 选项,您签入反应:

```{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())
```