title: Confidence Interval of Difference of Means between two datasets
body: <p>I'm working on two datasets, derrived fromm <code>cats</code>, an in-build R dataset. </p>
  
  <pre><code>&gt; cats
      Sex Bwt  Hwt
  1     F 2.0  7.0
  2     F 2.0  7.4
  3     F 2.0  9.5
  4     F 2.1  7.2
  5     F 2.1  7.3
  6     F 2.1  7.6
  7     F 2.1  8.1
  8     F 2.1  8.2
  9     F 2.1  8.3
  10    F 2.1  8.5
  11    F 2.1  8.7
  12    F 2.1  9.8
  ...
  137   M 3.6 13.3
  138   M 3.6 14.8
  139   M 3.6 15.0
  140   M 3.7 11.0
  141   M 3.8 14.8
  142   M 3.8 16.8
  143   M 3.9 14.4
  144   M 3.9 20.5
  </code></pre>
  
  <p>I want to find the <strong>99% Confidence Interval on the difference of means values</strong> between the Bwt of Male and Female specimens (Sex == M and Sex == F respectively)</p>
  
  <p>I know that <code>t.test</code> does this, among other things, but if I break up <code>cats</code> to two datasets that contain the <code>Bwt</code> of Males and Females, t.test() complains that the two datasets are not of the same length, which is true. There's only 47 Females in <code>cats</code>, and 87 Males.</p>
  
  <p>Is it doable some other way or am I misinterpreting data by breaking them up?</p>
  
  <p>EDIT:
  I have a function suggested to me by an Answerer on another Question that gets the CI of means on a dataset, may come in handy:</p>
  
  <pre><code>ci_func &lt;- function(data, ALPHA){
    c(
      mean(data) - qnorm(1-ALPHA/2) * sd(data)/sqrt(length(data)),
      mean(data) + qnorm(1-ALPHA/2) * sd(data)/sqrt(length(data))
      )
  }
  </code></pre>