I was wondering how to create a table with all the data from the user's csv file. I would like the data to be uploaded into a tabPanel. Currently, I am running into the issue that no data is being displayed.
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)
I'm not sure why the output$data <- renderTable(output$tableOne is not allowing the data to be displayed.