R shiny:反应函数中的fileInput问题(未找到ui)

时间:2018-04-18 20:02:46

标签: r shiny

我已经构建了一个闪亮的应用程序。它有时会起作用,有时会崩溃,我不知道该怎么做。

基本上,应用程序的想法是允许用户上传xlsx文件。该应用程序使用该算法并在应用程序上返回一个表。

目前我的问题是:

  

生效错误(ui):未找到对象'ui'

ui代码是

    ui<- 
  fluidPage(
    sidebarLayout(

    sidebarPanel(
      fileInput("file", "Upload the list", accept = c(".xlsx"), buttonLabel = "Seach"),
      sliderInput("max", "max in groups:",  
                  min = 11, max = 17, value=14),
      sliderInput("min", "min in groups:",  
                  min = 5, max = 9, value=7))),
    mainPanel(
    tableOutput('grouped')
  ))

server <- function(input,output){

  dataInput <- reactive({

    func <- function (val,valm) {


      # ====
      # ====== input ==========
      inFile<- input$file
      library(readxl)
      library(plyr)
      ext <- "xlsx"
      file.rename(inFile$datapath,
                  paste(inFile$datapath, ext, sep="."))
      members <- read_excel(paste(inFile$datapath, ext, sep="."), 1)

      #members <- read_excel(inFile$datapath)
      members$free <- 0
      members$free2 <- 0
      members$free3 <- 0
      members$freeENG <- 0
      members$freeENG[members$`English Required` == "no"] <- 1

      #View(members)

      groups <- data.frame("Effective Communication"=character(20), 
                           "Decision Making and Problem Solving"= character(20), 
                           "Feedback Is a Gift"=character(20),
                           "Fierce Accountability"=character(20),
                           "ME During Change"=character(20),
                           "Assertiveness Training"=character(20),
                           stringsAsFactors=FALSE)




      i=1
      miss = TRUE
      missENG = TRUE
      ECG= matrix(c(1, "Effective.Communication"),nrow=1)
      DMG= matrix(c(1, "Decision.Making.and.Problem.Solving"),nrow=1)
      FBG= matrix(c(1, "Feedback.Is.a.Gift"),nrow=1)
      FAG= matrix(c(1,"Fierce.Accountability"),nrow=1)
      MEG= matrix(c(1, "ME.During.Change"),nrow=1)
      ASG= matrix(c(1, "Assertiveness.Training"),nrow=1)
      indexes <- rbind(ECG,DMG,FBG,FAG,MEG,ASG)

      # ===========
      max= val
      min= valm

它没有完成......中间有几条线。但最终是:

      return(groups)  
    }

    func(input$max,input$min)})

  output$grouped <- renderTable({dataInput()}, spacing = 'xs', rownames= TRUE) 
}

shinyApp(ui=ui,server=server)

正如您所看到的,我在响应中构建了一个函数,它接受输入$ max并与fileInput一起输入$ min,然后重新启动“组”。 然后“groups”就是表输出。

我在这里做错了什么?

0 个答案:

没有答案