title: Why does the mean differ using summarySEwithin?
body: <p>When I use summarySEwithin.R the mean it produces is different to the means I have calculated through SPSS and other R scripts (aggregate).</p>
  
  <p>Why? Can I stop this and just get the mean? </p>
  
  <p>I have a mixed data set (routinefailure.NS), with one between-subject factor (Condition: None and Static), and one within-subject factor (Group: routine and failure).</p>
  
  <p>Does summarySEwithin normalise the mean? Can I use the mean from summarySE and the SE and CI from summarySEwithin? </p>
  
  <p>Here is what my dataset looks like:</p>
  
  <pre><code>head(routinefailure.NS)
  subj   Group Condition Class ClassRT  CPA CPART Dive DiveRT SAGAT ATWIT
  300 routine      None  0.66   10.41 0.56 30.00 0.80   5.90  0.64  6.31
  301 routine      None  0.90   19.54 0.32 28.46 0.86   5.42  0.65  5.47
  302 routine      None  0.97   32.14 0.48 23.76 0.94   6.02  0.77  3.89
  303 routine      None  0.93   23.73 0.33 35.32 0.90   5.57  0.45  5.72
  304 routine      None  0.82   14.37 0.29  6.84 0.88   5.70  0.62  6.19
  </code></pre>
  
  <p>Here is what I did</p>
  
  <blockquote>
    <p>summarySE(routinefailure.NS, measurevar = "Class", groupvars = c("Condition", "Group"), na.rm = TRUE)</p>
  </blockquote>
  
  <pre><code>Condition   Group  N     Class         sd          se         ci
  None       failure 30 0.8513333 0.17702003 0.032319288 0.06610037
  None       routine 30 0.8230000 0.16071285 0.029342018 0.06001117
  Static     failure 30 0.8440000 0.14194705 0.025915867 0.05300390
  Static     routine 30 0.9253333 0.05090446 0.009293841 0.01900804
  </code></pre>
  
  <blockquote>
    <p>summarySEwithin(routinefailure.NS, measurevar = "Class", betweenvars = "Condition", withinvars = "Group", idvar = "subj", na.rm = TRUE, conf.interval = 0.95)</p>
  </blockquote>
  
  <pre><code>Condition   Group  N     Class         sd         se         ci
  None       failure 30 0.8750833 0.06200899 0.01132124 0.02315454
  None       routine 30 0.8467500 0.06200899 0.01132124 0.02315454
  Static     failure 30 0.8202500 0.09081496 0.01658047 0.03391086
  Static     routine 30 0.9015833 0.09081496 0.01658047 0.03391086
  </code></pre>
  
  <p>I am not that good with R, but have managed until now. Any comment would be much appreciated!</p>