title: display multiple plots in a list using grid.arrange in R
body: <p>I want to display multiple plots depending on the length of my predictors. I have created two list and then used <code>grid.arrange</code> function to display the plots within these lists, but I am getting the following error message -<code>'only 'grobs' allowed in "gList"</code>. Even when I try to use only one list say p, I get the same error message. Please help!</p>
  
  <pre><code> library(ggplot2)
   library(gridExtra)
  
  
   # dependent1 variable
   # dependent2 variable 
   # predictor_vector is a vector of predictors
  
   plot_output(data, dependent1, dependent2, predictor_vector)
   {
  
   length&lt;-length(predictor_vector)
  
    p&lt;-list()
    g&lt;-list()
  
    for( i in 1:length)
    {
    p[[i]]&lt;-ggplot(data, aes(y=dependent1, x=predictor_vector[i]))
    g[[i]]&lt;-ggplot(data, aes(y=dependent2, x=predictor_vector[i]))
    }
  
  
    do.call("grid.arrange", c(p, g, list(ncol=2)))
  
   }
  </code></pre>