title: Creating a matrix from multiple column vectors
body: <p>How can I create a matrix from multiple column vectors?</p>
  
  <p>I know that I can easily create a data frame with column vectors:</p>
  
  <pre><code>&gt; colA &lt;- 1:5
  &gt; colB &lt;- 21:25
  &gt; colC &lt;- 31:35
  &gt; data.frame(colA, colB, colC)
    colA colB colC
  1    1   21   31
  2    2   22   32
  3    3   23   33
  4    4   24   34
  5    5   25   35
  </code></pre>
  
  <p>However, when I try <code>matrix()</code>, it gives me unexpected results, as shown below. How can create my desired matrix? I know I can do <code>as.matrix(df)</code>, which nicely preserves the column names, but I'm looking for a more direct approach.</p>
  
  <pre><code>&gt; matrix(colA, colB, colC)
        [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
   [1,]    1    2    3    4    5    1    2    3    4     5     1     2     3
   [2,]    2    3    4    5    1    2    3    4    5     1     2     3     4
   [3,]    3    4    5    1    2    3    4    5    1     2     3     4     5
   [4,]    4    5    1    2    3    4    5    1    2     3     4     5     1
   [5,]    5    1    2    3    4    5    1    2    3     4     5     1     2
   [6,]    1    2    3    4    5    1    2    3    4     5     1     2     3
   [7,]    2    3    4    5    1    2    3    4    5     1     2     3     4
   [8,]    3    4    5    1    2    3    4    5    1     2     3     4     5
   [9,]    4    5    1    2    3    4    5    1    2     3     4     5     1
  [10,]    5    1    2    3    4    5    1    2    3     4     5     1     2
  [11,]    1    2    3    4    5    1    2    3    4     5     1     2     3
  [12,]    2    3    4    5    1    2    3    4    5     1     2     3     4
  [13,]    3    4    5    1    2    3    4    5    1     2     3     4     5
  [14,]    4    5    1    2    3    4    5    1    2     3     4     5     1
  [15,]    5    1    2    3    4    5    1    2    3     4     5     1     2
  [16,]    1    2    3    4    5    1    2    3    4     5     1     2     3
  [17,]    2    3    4    5    1    2    3    4    5     1     2     3     4
  [18,]    3    4    5    1    2    3    4    5    1     2     3     4     5
  [19,]    4    5    1    2    3    4    5    1    2     3     4     5     1
  [20,]    5    1    2    3    4    5    1    2    3     4     5     1     2
  [21,]    1    2    3    4    5    1    2    3    4     5     1     2     3
        [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
   [1,]     4     5     1     2     3     4     5     1     2     3     4     5
   [2,]     5     1     2     3     4     5     1     2     3     4     5     1
   [3,]     1     2     3     4     5     1     2     3     4     5     1     2
   [4,]     2     3     4     5     1     2     3     4     5     1     2     3
   [5,]     3     4     5     1     2     3     4     5     1     2     3     4
   [6,]     4     5     1     2     3     4     5     1     2     3     4     5
   [7,]     5     1     2     3     4     5     1     2     3     4     5     1
   [8,]     1     2     3     4     5     1     2     3     4     5     1     2
   [9,]     2     3     4     5     1     2     3     4     5     1     2     3
  [10,]     3     4     5     1     2     3     4     5     1     2     3     4
  [11,]     4     5     1     2     3     4     5     1     2     3     4     5
  [12,]     5     1     2     3     4     5     1     2     3     4     5     1
  [13,]     1     2     3     4     5     1     2     3     4     5     1     2
  [14,]     2     3     4     5     1     2     3     4     5     1     2     3
  [15,]     3     4     5     1     2     3     4     5     1     2     3     4
  [16,]     4     5     1     2     3     4     5     1     2     3     4     5
  [17,]     5     1     2     3     4     5     1     2     3     4     5     1
  [18,]     1     2     3     4     5     1     2     3     4     5     1     2
  [19,]     2     3     4     5     1     2     3     4     5     1     2     3
  [20,]     3     4     5     1     2     3     4     5     1     2     3     4
  [21,]     4     5     1     2     3     4     5     1     2     3     4     5
        [,26] [,27] [,28] [,29] [,30] [,31]
   [1,]     1     2     3     4     5     1
   [2,]     2     3     4     5     1     2
   [3,]     3     4     5     1     2     3
   [4,]     4     5     1     2     3     4
   [5,]     5     1     2     3     4     5
   [6,]     1     2     3     4     5     1
   [7,]     2     3     4     5     1     2
   [8,]     3     4     5     1     2     3
   [9,]     4     5     1     2     3     4
  [10,]     5     1     2     3     4     5
  [11,]     1     2     3     4     5     1
  [12,]     2     3     4     5     1     2
  [13,]     3     4     5     1     2     3
  [14,]     4     5     1     2     3     4
  [15,]     5     1     2     3     4     5
  [16,]     1     2     3     4     5     1
  [17,]     2     3     4     5     1     2
  [18,]     3     4     5     1     2     3
  [19,]     4     5     1     2     3     4
  [20,]     5     1     2     3     4     5
  [21,]     1     2     3     4     5     1
  Warning message:
  In matrix(colA, colB, colC) :
    data length [5] is not a sub-multiple or multiple of the number of rows [21]
  </code></pre>