【发布时间】:2021-07-30 22:24:31
【问题描述】:
我想知道如何使用用户 csv 文件中的所有数据创建一个表。我希望将数据上传到 tabPanel。目前,我遇到了没有数据显示的问题。
library(shiny)
ui <- fluidPage(
navbarPage("Dashboard",
tabPanel(title = "Model",
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose .csv file", #add red asterisks to make this mandatory
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv"),
),
),
mainPanel(
tabsetPanel(
tabPanel("Data",
tableOutput("tableOne"))
)
)
)
)
)
)
server <- function(input,output){
data <- reactive({
file1 <- input$file
if(is.null(file1)){return()}
read.table(file=file1$datapath)
})
output$filedf <- renderTable({
if(is.null(data())){return ()}
input$file
})
output$tableOne <- renderTable({
if(is.null(data())){return ()}
data()
})
output$data <- renderTable(output$tableOne)
}
shinyApp(ui,server)
我不确定为什么 output$data
【问题讨论】:
-
@akrun 这里是完整代码