title: Is it possible to create a law of probability in R?
body: <p>I have a vector of probability and I want to sample one component from this vector  by taking into account the value of its probability.
  Here is an example:</p>
  
  <pre><code>x = [1/2,1/4,1/4]
  </code></pre>
  
  <p>The probability of taking 1 in x is 1/2, the probability for 2 and 3 is 1/4. How can I do that in R?</p>