title: Probability of random variable from group A being larger than group B
body: <p>I have two datasets that contain people's height (among other details) stored in data frames:</p>
  <pre><code>dataset1$height
  dataset2$height
  </code></pre>
  <p>I need to know the probability of a randomly selected height from dataset1 will be larger than a randomly selected height from dataset2.</p>
  <p>I'm aware I'm trying to calculate <code>P(X-Y)&gt;0</code> here, but I'm not sure how to put this in R, and how to get an answer for P (i.e. what is the probability that <code>dataset1$height - dataset2$height &gt; 0</code>).</p>
  <p>I've calculated the mean, variance and standard deviation for the height in each dataset, I'm just not sure how to fit these calculations into a formula that results in the probability.</p>
  <p>For reproducibility, the following samples could represent the what I have:</p>
  <pre><code>dataset1 = rnorm(100, mean = 11, sd = 2)
  dataset2 = rnorm(100, mean = 10, sd = 2)
  mean1 = mean(dataset1)
  mean2 = mean(dataset2)
  var1 = var(dataset1)
  var2 = var(dataset2)
  sdev1 = sd(dataset1)
  sdev2 = sd(dataset2)
  Probability = mean(dataset2)/mean(dataset1)
  Probability
  </code></pre>