title: Rearrange matrix by a condition
body: <p>I'd like to rearrange one matrix with a condition. If I have a data frame:</p>
  
  <pre><code># My data frame
  my_DF&lt;-c(1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,3,3,3,4,4,4,4,4,4,4)
  my_DF
  </code></pre>
  
  <p>and I need to convert it into a matrix, usually I do:</p>
  
  <pre><code># matrix convertion
  myMX&lt;-matrix(my_DF, ncol=7,nrow=4)
  myMX
       [,1] [,2] [,3] [,4] [,5] [,6] [,7]
  [1,]    1    1    2    2    3    3    4
  [2,]    1    1    2    2    3    4    4
  [3,]    1    1    2    3    3    4    4
  [4,]    1    2    2    3    3    4    4
  </code></pre>
  
  <p>But this solution doesn't return the desired output, as shown below:</p>
  
  <pre><code>  [,1] [,2] [,3] [,4] [,5] [,6] [,7]
       1    1    1    1    1    1    1
       2    2    2    2    2    2    2
       3    3    3    3    3    3    3
       4    4    4    4    4    4    4
  </code></pre>
  
  <p>What I can do to reach my desired solution? </p>