title: how to transpose different groups from column to row in R or excel
body: <p>I searched a few answers but it seems none can answer my question</p>
  
  <p>I have a data look like this (2 columns, 2 groups group"1" and group"2")</p>
  
  <ul>
  <li>1 10</li>
  <li>1 20</li>
  <li>1 50</li>
  <li>2 40</li>
  <li>2 30</li>
  <li>2 60</li>
  </ul>
  
  <p>and I want to transpose it from column to row by each group
  the result will look like this</p>
  
  <ul>
  <li>1   1  1 </li>
  <li>10 20 50</li>
  <li>2   2  2</li>
  <li>40 30 60</li>
  </ul>
  
  <p>Since I have a lot of groups, I cannot manually do it one by one. Could anyone please help me? Thank you.</p>
  
  <p>Thanks guys, since all groups have the same length (inspired by the comment from Floris), actually I can simply just use matrix to solve the problem</p>
  
  <pre><code>    x=read.table(header=F,text="10 20 50 40 30 60")
      matrix(x,nrow=2,byrow=T)
  </code></pre>