我有一个应用程序,允许我通过使用输入来查看过滤器的汽车数量。
这是我的代码。
```{r}
selectInput("input_type","Select Cylinder Size: ", c("All", mtcars$cyl))
selectInput("input_type2", "Select # of Gears: ", c("All", mtcars$gear))
mtcars2 <- reactive({
if(input$input_type=="All")
mtcars
else
subset(mtcars,cyl == input$input_type)
})
renderDataTable(
datatable(mtcars2())
)
```
虽然我有第二个输入也可以让我按齿轮过滤,但它不起作用,因为我不知道如何将它与反应函数联系起来。
有什么想法吗?