title: merging list of data frame with different number of columns in R?
body: <p>I have a huge list of data frame with different number of columns. I want to loop through each list of data frame and merge them despite the different number of columns.</p>
  <pre><code>data&lt;-list()
  data[[1]]&lt;-data.frame(x=c(1,4),b=c(7,8),d=c(5,4),y=c(4,7),h=c(8,5)
  data[[2]]&lt;-data.frame(x=c(1,NA),b=c(7,8),d=c(5,NA),y=c(4,NA),h=c(8,NA),a=c(NA,87),z=c(NA,7))
  </code></pre>
  <p>Here is my trial, but I am not getting the desired output :(</p>
  <pre><code> comined_df&lt;-function(index)
      {
        if (nrow(as.data.frame(data[index]))&gt;0)
          {
              cleaned_data_frame &lt;- dplyr::bind_rows(as.data.frame(data[index]))
          }
        else
          {
              return(NULL)
          }
      }
  
  combined_df_final&lt;-lapply(1:length(data), comined_df)
  </code></pre>
  <p>The desired output is as follows:</p>
  <pre><code>  x b  d  y  h  a  z
  1  1 7  5  4  8 NA NA
  2  4 8  4  7  5 NA NA
  3  1 7  5  4 NA NA NA
  4 NA 8 NA NA NA NA  7
  </code></pre>
  <p>Can anyone help me achieving this please?</p>