R Shiny-基于首选的过滤器

时间:2016-07-09 03:24:35

标签: r shiny

我正在编写一个闪亮的应用程序来显示基于两个过滤器(产品和费率)的表格。 第二个过滤器选择列表应基于第一个过滤器选择。

即,如果我从产品列过滤器中选择A,则速率列过滤器应仅显示“good”和“medium”。 (注:这是一个样本数据实际数据有大约100个类别)

data_test = data.frame(ID = c ("1","2","3","4","5"),
                       product = c("A","B","C","A","C"),
                       rate = c("good","medium","bad","medium","bad"),
                       cust = c(1,2,5,1,6)) 

目前我正在使用DT包。有人可以帮我用DT包来帮助我实现这个目的。

我目前使用的代码如下。

Server.R

library(shiny)
library(DT)

data_test = data.frame(ID = c ("1","2","3","4","5"),
                       product = c("A","B","C","A","C"),
                       rate = c("good","medium","bad","medium","bad"),
                       cust = c(1,2,5,1,6))

shinyServer(function(input, output) {

    output$table <- renderDataTable({ 
        data_test        
    },
    filter = 'top',
    rownames = FALSE)    
})

ui.R

library(shiny)
if (!require("DT")) install.packages('DT')
library(DT)

shinyUI(fluidPage(
    titlePanel("Product"),


                  dataTableOutput("table")


))

0 个答案:

没有答案