title: "Subscript out of bounds": Shiny renderPlot() with for loop to generate plots
body: <p>I'm trying to use a for loop to create scatter plots. list_grps represents a number of groups which contain data (i.e. each group in the list contains some number of columns from a dataframe). I'm then applying a function to create scatterplots over these lists and saving the output to a list (list_scatter_plots). When I try to renderPlot() for my plots, I get the message &quot;subscript out of bounds&quot;. The trace from shiny has the following additional details:</p>
  <pre><code>SEND {&quot;errors&quot;:{&quot;scatter&quot;:{&quot;message&quot;:&quot;subscript out of bounds&quot;,&quot;call&quot;:&quot;grobs[[i]]&quot;,&quot;type&quot;:null}},&quot;values&quot;:{},&quot;inputMessages&quot;:[]}
  </code></pre>
  <p>Sample dataset: <a href="https://docs.google.com/spreadsheets/d/1j63zpOKBFFtuNTWga3Da7ytUnBfwGRVucGIFUENVsQQ/edit?usp=sharing" rel="nofollow noreferrer">https://docs.google.com/spreadsheets/d/1j63zpOKBFFtuNTWga3Da7ytUnBfwGRVucGIFUENVsQQ/edit?usp=sharing</a></p>
  <p>This is the code:</p>
  <p>library(shiny)
  library(rio)
  library(DT)
  library(tidyverse)
  library(ggpubr)</p>
  <pre><code>ui &lt;- navbarPage(&quot;App Name&quot;,
                   tabPanel(&quot;File Upload&quot;,
                            sidebarLayout(
                              sidebarPanel(
                                tags$h1(tags$b(&quot;File Upload&quot;)),
                                fileInput(&quot;file1&quot;,
                                          &quot;Choose File&quot;,
                                          multiple = FALSE,
                                          accept = c(&quot;text/csv&quot;,
                                                     &quot;text/tab-separated-values&quot;,
                                                     &quot;.csv&quot;,
                                                     &quot;text/tsv&quot;,
                                                     &quot;text/comma-separated-values&quot;,
                                                     &quot;.tsv&quot;)),
                                placeholder = &quot;No file selected&quot;,
                                tags$hr(),
                                selectInput(&quot;dftype&quot;, label = &quot;Data Type&quot;,
                                            choices = c(Phosphoproteome = &quot;pProt&quot;,
                                                        Proteome = &quot;Prot&quot;),
                                            selected = &quot;Prot&quot;),
                                tags$hr(),
                                tags$h1(tags$b(&quot;Select Groups&quot;)),
                                tags$p(&quot;Select columns on table, then press 'Create new biological group' to group selected samples.&quot;),
                                actionButton(&quot;cr_grp&quot;, &quot;Create new biological group&quot;)
                              ),
                              mainPanel(
                                DT::dataTableOutput(outputId = &quot;exp_df&quot;)
                              )
                            )),
  tabPanel(&quot;Quality Control&quot;
                           sidebarPanel(
  
                           ),
                           mainPanel(
                             plotOutput(outputId = &quot;scatter&quot;)
                           )
                  ))
  
  server &lt;- function(input, output, session) {
    exp_dff &lt;- eventReactive(input$file1,{
      infile &lt;- input$file1
      req(infile)
      return(select(import(infile$datapath), -starts_with(c(&quot;Boost&quot;, &quot;Empty&quot;, &quot;MaxPepProb&quot;, &quot;ReferenceIntensity&quot;))))
    })
  output$exp_df &lt;- DT::renderDataTable(exp_dff())
    
    list_grps &lt;- list()
  
    observeEvent(input$cr_grp, {
      append(list_grps, input$exp_df_columns_selected)
    })
  
  list_scatter_plots &lt;- lapply(list_grps, function(x) pairs(x, pch=20, col=“red”))
  
   output$scatter &lt;- renderPlot(ggarrange(plotlist = list_scatter_plots))
  }
  
  shinyApp(ui=ui, server=server)
  </code></pre>