title: transpose data frame
body: <p>I am using R to transpose a data frame from an excel file (mydata.xls).
  The original data frame looks like this:</p>
  
  <pre><code>ID         AB_1  AB_2  AB_3  AB_4  AB_5
  Variable1  1     2     3     4     5
  Variable2  1.5   2.8   4.5   5.6   7.8
  </code></pre>
  
  <p>This is what I would like to achieve:</p>
  
  <pre><code>ID    Variable1   Variable2
  AB_1  1           1.5
  AB_2  2           2.8
  AB_3  3           4.5
  AB_4  4           5.6
  AB_5  5           7.8
  </code></pre>
  
  <p>Here is what I did, according to the response on a <a href="https://stackoverflow.com/questions/7970179/transposing-a-dataframe-maintaining-the-first-column-as-heading">similar post in the past</a>.</p>
  
  <pre><code>Library(XLConnect)
  x=loadWorkbook("mydata.xls")
  y=readWorksheet(x,"Summary")
  z=setNames(data.frame(t(y[,-1])),y[,1])
  </code></pre>
  
  <p>However, here is what I got:</p>
  
  <pre><code>z    
        Variable1   Variable2
  AB_1  1           1.5
  AB_2  2           2.8
  AB_3  3           4.5
  AB_4  4           5.6
  AB_5  5           7.8
  </code></pre>
  
  <p>Two problems are noticed:
  1."ID" is missing.
  2. when I checked the first column of the new data frame, the second column was returned (see below)</p>
  
  <pre><code>z[,1]
  [1] 1 2 3 4 5
  </code></pre>
  
  <p>I wonder 1) what happened to the "ID" and that entire column? 2) How the issues could be fixed?</p>