title: aggregate/ merge a list of dataframes by variable names (R)
body: <p>I have a list of dataframes which look similiar to this:</p>
  <pre><code>Date &lt;-  c(&quot;Jan-22&quot;, &quot;Dec-21&quot;, &quot;Nov-21&quot;, &quot;Sep-21&quot;)
  A_B &lt;- c(5,6,7,9)
  A_C &lt;- 1:4
  B_D &lt;- 4:7
  df1 &lt;- data.frame(Date, A_B, A_C, B_D)
  
  Date &lt;-  c(&quot;Jan-22&quot;, &quot;Dec-21&quot;, &quot;Nov-21&quot;, &quot;Sep-21&quot;)
  A_C &lt;- 1:4
  B_D &lt;- 13:16
  D_F &lt;- c(5,6,7,8)
  df2 &lt;- data.frame(Date, A_C, B_D, D_F)
  
  ListofDF &lt;- list(df1, df2)
  </code></pre>
  <p>My original List contain some more dataframes and my dataframes more Variables, but all share the Variable Date (as Character). Now I would like to merge/ aggregate all the different dataframes in the list to one.
  So it should merge acording the Date column and aggegate (mean) the Variables Values, if those names are the same.</p>
  <p>My disired output would be somthing like that</p>
  <pre><code>Date &lt;-  c(&quot;Jan-22&quot;, &quot;Dec-21&quot;, &quot;Nov-21&quot;, &quot;Sep-21&quot;)
  A_B &lt;- c(5,6,7,9)
  A_C &lt;- 1:4
  B_D &lt;- c(8.5, 9.5, 10.5, 11.5)
  D_F &lt;- c(5,6,7,8)
  
  df3 &lt;- data.frame(Date,A_B, A_C, B_D, D_F)
  </code></pre>
  <p>So same dates, but the mean of values, if there are the same variable names.</p>
  <p>i hope I could clarify what I need and thanks in andavance.</p>
  <p><strong>Edit</strong>
  Finally I found a solution:</p>
  <pre><code>MyOutput1&lt;- List1 %&gt;% reduce(full_join, by = &quot;Date&quot;)
  
  List2 &lt;- melt(MyOutput1, id.vars = &quot;Date&quot;)
  
  res &lt;- aggregate(value ~ Date + variable, 
                   transform(List2, variable = sub(&quot;\\..*&quot;, '', variable)), mean, na.rm = TRUE)
  </code></pre>
  <p>Still I think its not a very nice solution, does anyone have any Idea for a better solution?</p>