R闪亮输出作为表错误,具体取决于输入变化

时间:2016-09-20 18:49:43

标签: r shiny

我已经解决了这个编程但是在更改输入时我无法找到输出更改作为表格请任何人都可以帮我使用R闪亮代码

我已经解决了错误,但它仍然只显示

library(shiny)
library(DT)
bcl <- read.csv("R-D.csv", stringsAsFactors = FALSE)

ui <- shinyUI(fluidPage(
sidebarLayout(
sidebarPanel(
  radioButtons("TYPE.OF.DATA","View data by:", choices = c("NP", "CR",      "AN"), inline = TRUE, selected = "NP"),

  tags$hr(),

  radioButtons(" LINE.OF.BUSINESS ","View data by:" ,choices = c("AF",       "HL"), inline = TRUE, selected = "AF"),
  tags$hr(),

  selectInput("typeInput6", " APPLICATION ",
              choices = c("TERADATA"),
                 selected = "TERADATA"),
  tags$hr(),

    radioButtons( "DatabaseName","View data by:",choices = c("DW_re",    "DW_np",       "DW_AN"), inline = TRUE, selected = "DW_re")

  ),  
  mainPanel(
  DT::dataTableOutput("table") 
  )
 )
))



  server <- shinyServer(function(input, output,session) {

 observe({
  if(input$bcl == "TYPE.OF.DATA"){
  choices = c("NP", "CR", "AN")
    firstchoice = "NP"
  label = "DATA TYPE:"
   }else{
  choices = c("DW_re", "DW_np", "DW_AN")
  firstchoice = "DW_re"
    label = "NAME:"
}
     updateSelectInput(session, "bcl", label = label, choices = choices,       selected = firstchoice)
 })

 data <- reactive({
 data = switch(input$bcl,
              "NP" = NP, "CR" = CR, "AN" = AN,
              "DW_re" = DW_re, "DW_np" = DW_np, "DW_AN" = DW_AN
  )

 })

  output$table <- DT::renderDataTable({
 datatable(data())

  })
})

shinyApp(ui=ui,server=server)  

0 个答案:

没有答案