Hi,
I've really been struggling to create an app that allows the user to choose a file to display as a table.
(The files are stored on the server and the number of files varies depending on the users input.)
Here is some code that I think is going in the right direction. It creates a given number of tables for just one of the files, but that is because "data/0.tsv" is hardcoded in. What I am getting at is if I have 10 tsv files how could I allow the user to display a given file of their choosing?
Thanks a lot for any help.
library(shiny)
library(DT)
ui <- fluidPage(
sidebarLayout(
sidebarPanel(
selectInput("amountTable", "Amount Tables", 1:5)
),
mainPanel(
# UI output
uiOutput("dt")
)
)
)
server <- function(input, output) {
observe({
lapply(1:input$amountTable, function(num_tbl) {
output[[paste0('T', num_tbl)]] <- renderTable({
head(read.table("data/0.tsv", header = FALSE, sep = "\t", col.names = c("Anatomy Term", "Count")))
})
})
})
output$dt <- renderUI({
tagList(lapply(1:input$amountTable, function(num) {
tableOutput(paste0('T', num))
}))
})
}
shinyApp(ui, server)