title: Generate all vectors of certain length with 0 or 1 elements
body: <p>I need to generate all possible vectors with elements 0 or 1 of a certain length. </p>
  
  <p>For example, here the length is 6, I need all the vectors:</p>
  
  <pre><code>(0,0,0,0,0,0),(0,0,0,0,0,1),...,(1,1,1,1,1,1)
  </code></pre>
  
  <p>Searching around, I found a way to make the vector <code>y</code> below which contains 64 character strings <code>"000000","000001",...,"111111"</code>, but now I am stuck not knowing how to convert each of these strings into the relevant vector.</p>
  
  <pre><code>x &lt;- seq(0,2^6-1,1)
  library(R.utils)
  y &lt;- inToBin(x)
  </code></pre>
  
  <p><strong>Edit:</strong> I figured out how to do this:</p>
  
  <pre><code>z &lt;- matrix(NA,nrow=length(y),ncol=6)
  for(i in 1:length(y)){
    z[i,] &lt;- as.numeric(strsplit(y[i],"")[[1]])
  }
  </code></pre>