R 闪亮应用程序-条件选择
我有一个基本的闪亮的应用程序,可以显示结果(4列),可以过滤掉一些结果 这些列通过层次结构相互连接:R 闪亮应用程序-条件选择,r,shiny,R,Shiny,我有一个基本的闪亮的应用程序,可以显示结果(4列),可以过滤掉一些结果 这些列通过层次结构相互连接: 产品类别(家具、食品等) 产品类型(餐桌、橙子、苹果等) 产品颜色(黄色、绿色等) 我使用的数据表如下所示 产品类别---产品类型---产品颜色 当我选择一个产品类别(比如水果)时,我仍然可以在产品类型选择框中看到实例“table”。所以我想用我在另一个框中选择的内容来限制我在一个框中看到的内容。可能吗?我对R和Shinny很陌生,我不确定我是否使用了正确的术语来搜索这个问题 library
- 产品类别(家具、食品等)
- 产品类型(餐桌、橙子、苹果等)
- 产品颜色(黄色、绿色等)
library(shiny)
library(ggplot2)
library(shinydashboard)
library(DT)
ui<-fluidPage(
titlePanel("Product catalogue"),
# Create a new Row in the UI for selectInputs
fluidRow(
column(4,
selectInput("ProductCategory",
"ProductCategory:",
c("All",
unique(as.character(Prod$ProductCategory))))
),
column(4,
selectInput("ProductType",
"ProductType:",
c("All",
unique(as.character(Prod$ProductType))))
),
column(4,
selectInput("ProductColor",
"ProductColor:",
c("All",
unique(as.character(Prod$ProductColor))))
)
),
# Create a new row for the table.
fluidRow(
DT::dataTableOutput("table")
))
server<- function(input, output) {
# Filter data based on selections
output$table <- DT::renderDataTable(DT::datatable({
data <- Prod
if (input$ProductCategory!= "All") {
data <- data[data$ProductCategory== input$ProductCategory, ]
}
if (input$ProductType!= "All") {
data <- data[data$ProductType== input$ProductType,]
}
if (input$ProductColor!= "All") {
data <- data[data$ProductColor == input$ProductColor,]
}
data
})
库(闪亮)
图书馆(GG2)
图书馆(shinydashboard)
图书馆(DT)
UIT此答案涵盖动态选择输入筛选:@RussellShepherd非常感谢!我将尝试此解决方案并更新帖子。它非常有效,非常感谢@RussellShepherd此答案包括动态选择输入筛选:@RussellShepherd非常感谢!我将尝试这个解决方案并更新帖子。它非常有效,非常感谢@RussellShepherd