Aggregate Data by date
<p>I'm working on the following dataframe:</p>

<pre><code>VAL1 &lt;- c("AA", "BB", "CC", "DD", "BB", "DD", "AA", "DD")
D01012016 &lt;- c(2, 4, 2, 6, 8, 8, 12, 4)
D02012016 &lt;- c(3, 3, 2, 1, 1, 2,4, 4)
D03022016 &lt;- c(2, 2, 3, 4, 3, 5, 5, 7)
D05022016 &lt;- c(1, 3, 3, 1, 2,3, 3, 6)
D03032016 &lt;- c(2, 1, 1, 1, 5, 3, 2, 1)
D01042016 &lt;- c(2, 4, 2, 6, 8, 8, 12, 4)
D02042016 &lt;- c(3, 3, 2, 1, 1, 2,4, 4)
D03042016 &lt;- c(2, 2, 3, 4, 3, 5, 5, 7)
D05042016 &lt;- c(1, 3, 3, 1, 2,3, 3, 6)
D05052016 &lt;- c(2, 3, 7, 1, 1, 1, 1, 1)
D23062016 &lt;- c(2, 1, 1, 1, 5, 3, 2, 1)
D05072016 &lt;- c(1, 3, 3, 1, 2,3, 3, 6)
D03082016 &lt;- c(2, 1, 1, 1, 5, 3, 2, 1)
D01092016 &lt;- c(2, 4, 2, 6, 8, 8, 12, 4)
D12092016 &lt;- c(3, 3, 2, 1, 1, 2,4, 4)
D05102016 &lt;- c(2, 1, 1, 1, 5, 3, 2, 1)
D21112016 &lt;- c(2, 4, 2, 6, 8, 8, 12, 4)
D13122016 &lt;- c(3, 3, 2, 1, 1, 2,4, 4)
df &lt;- data.frame(D01012016, D02012016, D03022016,D05022016,D03032016,D01042016,D02042016,D03042016,D05042016,D05052016,D23062016,D05072016,D03082016,D01092016,D12092016,D05102016,D21112016,D13122016)
</code></pre>

<p>Colnames are dates in the format Dddmmyyyy, i need to group data, mantaining in the first column <code>VAL1</code> (repeated values of VAL must remain separated) and group its monthly values (second <code>colnames</code> on have to be the months name, and data has to be aggregated with sum() function).
Final dataset must have the same number of rows( and all VAL1 must be in the same position) and having only 12 columns (one per month)</p>