shiny - 我可以在服务器上上传 csv 文件,但它没有显示在主面板或闪亮的仪表板主体面板中
问题描述
我正在使用闪亮的应用程序开发一个 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)
我希望查看用户上传到主面板或闪亮仪表板空间的 csv 文件。
错误 - 警告:错误!:无效的参数类型。
解决方案
您正在使用该变量input$header
,但它没有被创建。我建议删除input$header
服务器中的,或input$header
在 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")
)),
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)
推荐阅读
- slack - 在 SLACK 中收听消息
- flutter - Flutter - 用于浮动反应的插件,如 Facebook
- html - 如何将它与 Flexbox 对齐?
- oracle - ORACLE 10G,我是 oracle 10g 的新手。如何在没有联合的情况下对查询进行语法并并排查看列
- android - Android Studio 用触摸板滚动是可怕的
- c# - 在特定视图部分崩溃
- sql - Cognos 11.1.7 框架管理器更改查询主题的表,键入数据
- python - RGB 图像上的 Conv 自动编码器在 Pytorch 中不起作用
- java - Thymeleaf:处理和编辑由参考属性组成的列表
- c# - 过滤不等哈希集列表