我可以在服务器上上传 csv 文件,但它没有显示在主面板或闪亮的仪表板主体面板中

I am able to upload the csv file on the server but its not displaying in the main panel or in the shiny dashboard body panel

我正在使用闪亮的 App 开发 Web 应用程序,我不熟悉可用于构建应用程序的闪亮和仪表板。我以上传数据到服务器为例,但上传后我无法在主面板或仪表板区域查看。

library(shiny)
library(shinydashboard)
ui <- dashboardPage(
  dashboardHeader(title = strong ("OMNALYSIS")),
  dashboardSidebar(fileInput("file1", "Upload Expression Data",
                                accept = c(
                                  "text/csv",
                                  "text/comma-separated-values,text/plain",
                                  ".csv"),

  )),
  dashboardBody(
    tableOutput("contents")

  )
)
server <- function(input, output) {`enter code here`
  output$contents <- renderTable({

    inFile <- input$file1

    if (is.null(inFile))
      return(NULL)

    read.csv(inFile$datapath, header = input$header)
  })
}

shinyApp(ui, server)         

我希望查看用户上传到主面板或闪亮仪表板 space 的 csv 文件。

error - Warning: Error in !: invalid argument type.

您正在使用变量 input$header 但它并未被创建。我建议删除服务器中的 input$header,或在 UI.

中创建 input$header

从服务器中删除:

library(shiny)
library(shinydashboard)
ui <- dashboardPage(
  dashboardHeader(title = strong ("OMNALYSIS")),
  dashboardSidebar(fileInput("file1", "Upload Expression Data",
                             accept = c(
                               "text/csv",
                               "text/comma-separated-values,text/plain",
                               ".csv")
                             
  )),
  dashboardBody(
    tableOutput("contents")
  )
)
server <- function(input, output) {#'enter code here'
  output$contents <- renderTable({
    inFile <- input$file1
    if (is.null(inFile))
      return(NULL)
    read.csv(inFile$datapath)
  })
}   
shinyApp(ui, server) 

将其添加到 UI :

library(shiny)
library(shinydashboard)
ui <- dashboardPage(
  dashboardHeader(title = strong ("OMNALYSIS")),
  dashboardSidebar(fileInput("file1", "Upload Expression Data",
                             accept = c(
                               "text/csv",
                               "text/comma-separated-values,text/plain",
                               ".csv")),
  checkboxInput("header", "Header")
  ),
  dashboardBody(
    tableOutput("contents")
    
  )
)
server <- function(input, output) {#'enter code here'
  output$contents <- renderTable({
    inFile <- input$file1
    if (is.null(inFile))
      return(NULL)
    read.csv(inFile$datapath, header = input$header)
  })
}
shinyApp(ui, server)