title: R_Sample with probabilities
body: <p>I am having some problem with understanding the <code>prob</code> in <code>sample</code>. For example I want to create a sample data set of size 100 with integers 1,2,3 &amp; 4. I am using a probability of 0.1,0.2,0.3 &amp; 0.4 respectively.</p>
  
  <blockquote>
    <p>sample1&lt;-sample(1:4,100,replace=T,prob=seq(0.1,0.4,0.1))</p>
  </blockquote>
  
  <p>So, now I am expecting a sample with integers of 1,2,3 &amp; 4 repeating 10,20,30 &amp; 40 times respectively. But the result is different </p>
  
  <pre><code>&gt; table(sample1)
  sample1
   1  2  3  4 
   7 24 33 36 
  </code></pre>
  
  <p>Can anyone explain this? And what should I do if I want to get the expected results which is </p>
  
  <pre><code>&gt; table(sample1)
      sample1
       1  2  3  4 
      10 20 30 40 
  </code></pre>