title: Reshaping in R (...ala SAS PROC Transpose)
body: <p>I have the following table in R. I want to transpose it. I am new to R and have been using SAS. </p>
  
  <p>So I want to have a replica of proc transpose is SAS. I am giving the output also in which format I want it.</p>
  
  <pre><code>C_number&lt;-c(1:20)
  REG&lt;-letters[1:20]
  Market&lt;-c(21:40)
  DF&lt;-data.frame(C_number,REG,Market)
  n &lt;- nrow(DF)
  DF$A_count &lt;- sample(100, n, replace=TRUE) 
  DF$B_count &lt;- sample(100, n, replace=TRUE) 
  </code></pre>
  
  <p>the OUTPUT should be:</p>
  
  <pre><code>C_number          REG       Market      Name of former variable          Mem_count1
  1                  A        21          A_count                           5
  1                  A        21          B_count                           80
  2                  B        22          A_count                           36
  2                  B        22          B_count                           56
  3                  C        23          A_count                           77
  3                  C        23          B_count                           26
  </code></pre>
  
  <p><strong>So, the basic idea behind the transpose is to convert two columns A_count &amp; B_count into one named as "name of former variable" and creating a new column mem_count1 which will give the respective values.</strong> </p>
  
  <p>Its not exactly a transpose but kind of similar. I have no clue how to do this. Please help me solve this problem.</p>