title: R, generate number vector only contains 0 and 1, with certain length
body: <p>I wanted to create a list/vector like this:</p>
  
  <pre><code>c(0,0,0,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1)
  </code></pre>
  
  <p>or</p>
  
  <pre><code>c(0,0,1,0,1,0,1,1,1,1,0,1,0,1,1,0,1)
  </code></pre>
  
  <p>the length of this vector is a variable 'X', and the position of 0 and 1 are totally random.  </p>