I am creating a basic Shiny app. It enables the user to select how many groups to compare (in downstream analysis), and then based on this information (i.e. how many groups), fileInput boxes appear to select files for EACH group. However, when uploading files, it doesn't allow the user to upload different files for each fileInput selection. If I select files for the first fileInput section, the next fileInput section won't let me select a new bunch of files. I was using the information from this post:
https://stackoverflow.com/a/19131027/20812519
To dynamically change the amount of file inputs required.
library(shiny)
# Define UI f
ui <- fluidPage(
# Application title
titlePanel("Analysis"),
# Sidebar
sidebarLayout(
sidebarPanel(
numericInput("group_num", "How many independent variables are you comparing", 2, min = 1, max = 20),
uiOutput("groups"),
uiOutput("files")
),
# Show a plot of the generated distribution
mainPanel(
uiOutput("table")
)
)
)
# Define server logic
server <- function(input, output) {
output$groups <- renderUI({
group_num <- as.integer(input$group_num)
lapply(1:group_num, function(i){
textInput("group1", "Enter the name of each of your independent groups")
})
})
output$files <- renderUI({
group_num <- as.integer(input$group_num)
lapply(1:group_num, function(i){
fileInput("file1", "Select the .csv files from each independent group", multiple = TRUE, accept= ".csv")
})
})
}
# Run the application
shinyApp(ui = ui, server = server)
I realize it is probably because the file1 ID is not dynamically changing also with each iteration. Also, how can I paste the answers to the text Input section in the main panel?