【发布时间】:2021-08-29 06:39:07
【问题描述】:
我目前可以上传 .csv 文件,但是当我尝试上传 .xlsx 或 .xls 文件时,我收到错误消息。 “read.table 中的警告(文件 = 文件,标题 = 标题,sep = sep,quote = quote,: readTableHeader 在“/var/folders/k7/s4xbp26d059b_sm6q08hl5mm0000gn/T//Rtmp6mzvQO/de97a3667d0706ae06136c4b/0.xlsx”上找到的不完整的最后一行
这是我目前拥有的。
library(shiny)
library(xlsx)
population <- read.xlsx("population.xlsx", 1)
fieldsMandatory <- c("selectedCountry", "modelSelect", "seedData")
labelMandatory <- function(label) {
tagList(
label,
span("*", class = "mandatory_star")
)
}
appCSS <-
".mandatory_star {color: red;}"
appCSS <- ".invisible {display:none;}"
ui <- fluidPage(
div(
class = "invisible",
titlePanel("Spatial Tracking of COVID-19 using Mathematical Models")
),
navbarPage(title = span("Spatial Tracking of COVID-19 using Mathematical Models", style = "color:#000000; font-weight:bold; font-size:15pt"),
tabPanel(title = "Model",
sidebarLayout(
sidebarPanel(
fileInput("seedData", labelMandatory ("Upload initial seed data (.csv or .xls or .xlsx)"),
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv",
".xls",
".xlsx"),
),
),
mainPanel(
tabPanel("Initial Seed Data",
tableOutput("tableSeed")),
)
)
)
)
)
server <- function(input, output, session){
}
shinyApp(ui,server)
【问题讨论】:
-
read.table需要 csv 或 txt。您可能需要.xlsx的软件包,即read_excel(readxl)或read.excel(来自xlsx) -
感谢您的回复。我已经下载了 xlsx 包,它仍然给我同样的错误。
-
好的,您的代码不可重现以进行测试
-
我已将代码更新为可测试
-
当我复制你的代码时,它显示
upload completefor xlsx 或 csv。您代码中的服务器部分为空