title: Randomly select a sample in R
body: <p>I have to find a way to randomly choose a sample, in R, from the set S. The set S is composed by samples from I1 set. </p>
  
  <pre><code>I1 &lt;- c(1,2,3,4,5,6)
  s1 &lt;- c(1,2,1)
  s2 &lt;- c(1,5,6)
  s3 &lt;- c(2,1,1)
  s4 &lt;- c(5,1,1,6)
  s5 &lt;- c(3,4)
  s6 &lt;- c(4,3) 
  </code></pre>
  
  
  
  <p>Every sample has a P value assigned from 0 to 1. I need to find the best way to generate a number from 0 to 1 and select the corresponding sample. This is what i did: </p>
  
  <pre><code>x &lt;- runif(1, min = 0, max = 100) 
  if(x&gt;=0 &amp; x&lt;=20) {                
    print("s1")
  }
  if (x&gt;=21 &amp; x&lt;=30) {
    print("s2")
  }
  if(x&gt;=31 &amp; x&lt;=40) {
    print("s3")
  }
  if(x&gt;=41 &amp; x&lt;=65) {
    print("s4")
  }
  if(x&gt;=66 &amp; x&lt;=80) {
    print("s5")
  }
  if(x&gt;=81 &amp; x&lt;=100) {
    print("s6")
  }
  </code></pre>
  
  <p>Does anyone know a better way to do that ?</p>