R : Add dynamic column name to row in R : <p>Sample Data :</p>

<pre><code>df &lt;- data.frame(ProdCode = c("C1","C2"), ProdName = c("Product 1", "Product 2"), Category = c("Categ 1", "Categ 2"), "Jan-16" = c(3,2), "Apr-16" = c(3,""), "Jul-16" = c(5,2), "Oct-16" = c(5,2))
</code></pre>

<p>The value corresponding each month and product cell is rating for that product. That need to be in Rating column in output dataframe:</p>

<pre><code>&gt; df
  ProdCode  ProdName Category Jan.16 Apr.16 Jul.16 Oct.16
1       C1 Product 1  Categ 1      3      3      5      5
2       C2 Product 2  Categ 2      2             2      2
</code></pre>

<p>I've above data which is required in below format:</p>

<pre><code>ProdCode  Product.Name  Category    Rating.Date   Rating
C1          Product 1   Categ 1     Jan-16         3
C1          Product 1   Categ 1     Apr-16         3
C1          Product 1   Categ 1     Jul-16         5
C1          Product 1   Categ 1     Oct-16         5
C2          Product 2   Categ 2     Jan-16         2
C2          Product 2   Categ 2     Jul-16         2
C2          Product 2   Categ 2     Oct-16         2
</code></pre>

<p>The month column are dynamic and it will increase such as in future as per product it will come as Jan-2017 etc. I could do it by using for loop but that won't worth of using R.</p>
