title: simulating rolling two dice
body: <p>I am trying to simulate rolling two dice. I used:</p>
  
  <pre><code>d2 &lt;- sample(1:6, 10^6, replace = T) + sample(1:6, 10^6, replace = T)
  </code></pre>
  
  <p>and get the expected result. I also tried</p>
  
  <pre><code>s2d &lt;- c()
  for (i in 1:6) { 
    for (j in 1:6){ 
      s2d &lt;- c(s2d, (i+j)) 
    } 
  }
  d2 &lt;- sample(s2d, 10^6, replace=T)
  </code></pre>
  
  <p>and that works too,  but these feel a bit "brute force." Is there an easier,  more elegant way to do it? </p>
  
  <p>In more general terms, is there a function that takes 2 (or more) independent events and does operations on them (addition, multiplication)? </p>