0

我正在尝试为工作表中的datatable对象构建选择器flexmarkdown

所以这是我当前的(示例)布局,我正在尝试构建一个反应选择器,该选择器采用左侧的矿物类型输入,然后重新渲染整个表格以仅在此选择“Rock Type = Type 1”案子。

完整源代码@pastebin:链接

我当前的选择器:

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

```

我可以通过执行以下操作来实现这一点,但我还想为所有/无分组建立一个选择。

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

renderDataTable(dataInput())
```

当前布局

4

1 回答 1

1

您可以将All选项添加到您的 selectInput 中,您可以签入反应式:

```{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())
```
于 2017-01-24T21:01:49.357 回答