Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
clarify question
Link
MM1
  • 516
  • 3
  • 19

Displaying output of multiple csv files from multiple groups in Shiny

added 73 characters in body
Source Link
MM1
  • 516
  • 3
  • 19
  1. Enable the user to select how many groups of datasets to input (done).
  2. Enables the user to select multiple CSV files for each group. E.g. If I have selected 3 in step 1, three fileInput boxes appear to enter the files. (done)
  3. Rbind the files selected for each group. (help!)
  4. Display the rbinded datasets in a new tab (raw data) for each independent group. (help!) The data that is being inputted by the user has the same exact columns.
  1. Enable the user to select how many groups of datasets to input (done).
  2. Enables the user to select multiple CSV files for each group. E.g. If I have selected 3 in step 1, three fileInput boxes appear to enter the files. (done)
  3. Rbind the files selected for each group. (help!)
  4. Display the rbinded datasets in a new tab (raw data) for each independent group. (help!)
  1. Enable the user to select how many groups of datasets to input (done).
  2. Enables the user to select multiple CSV files for each group. E.g. If I have selected 3 in step 1, three fileInput boxes appear to enter the files. (done)
  3. Rbind the files selected for each group. (help!)
  4. Display the rbinded datasets in a new tab (raw data) for each independent group. (help!) The data that is being inputted by the user has the same exact columns.
Source Link
MM1
  • 516
  • 3
  • 19

Displaying output of multiple csv files in Shiny

I have a shiny app. I am having trouble displaying the output of multiple csv files in the main panel of the raw data tab. This is my workflow:

  1. Enable the user to select how many groups of datasets to input (done).
  2. Enables the user to select multiple CSV files for each group. E.g. If I have selected 3 in step 1, three fileInput boxes appear to enter the files. (done)
  3. Rbind the files selected for each group. (help!)
  4. Display the rbinded datasets in a new tab (raw data) for each independent group. (help!)

I'm sure it is a simple solution, I just can't get it working. This is the basis of my code

ui <- fluidPage( theme = bs_theme(version = 4, bootswatch = "pulse"), # Application title titlePanel(HTML("<center>Analysis</center>")), sidebarLayout( sidebarPanel( #begin tab conditionalPanel(condition = "input.tabselected==3", numericInput( "group_num", "How many independent variables are you comparing", 2, min = 1, max = 20 ), uiOutput("groups"), actionButton("save_btn", "Save Variables"), uiOutput("files")), actionButton("save_files", "Save Files"), ), mainPanel( tabsetPanel(type = "tabs", id = "tabselected", selected = 3, #Default tab selected is 3 tabPanel("Begin", textOutput("text1"), verbatimTextOutput("saved_variables"), value = 3), tabPanel("Raw Data", tableOutput("raw_data")), tabPanel("Stats", textOutput("stats_choice")), tabPanel("Data", tableOutput("out_data")), ) ) ) ) server <- function(input, output) { # Generate dynamic text input fields based on the number of groups output$groups <- renderUI({ group_num <- as.integer(input$group_num) lapply( 1:group_num, function(i){ textInput( paste0("group", i), paste0("Enter the name of group ", i) ) } ) }) # Generate dynamic file input fields based on the number of groups output$files <- renderUI({ group_num <- as.integer(input$group_num) lapply( 1:group_num, function(i){ fileInput( paste0("file", i), paste0( "Select the .csv file for group ", i), multiple = TRUE, accept= ".csv" ) } ) }) # Save the text inputs as variables when the button is clicked saved_variables <- reactiveValues() observeEvent(input$save_btn, { group_num <- as.integer(input$group_num) saved_variables$names <- sapply(1:group_num, function(i) input[[paste0("group", i)]]) }) # Generate the output text output$text1 <- renderText({ if (is.null(input$group_num)) { return() } group_num <- as.integer(input$group_num) variables <- saved_variables$names paste0( "You are comparing ", group_num, " independent variables. ", "The groups are called ", paste(variables, collapse = ", "), "." ) }) # Display the saved variables output$saved_variables <- renderPrint({ req(saved_variables$names) saved_variables$names }) output$stats_choice <- renderText({paste0("test4")}) output$out_data <- renderText({paste0("test5")}) } # Run the application shinyApp(ui = ui, server = server)