title: Repeated measures in time ANOVA
body: <p>I have a simple dataset with two treatments (trt), 3 reps and repeated measures at different dates. The response variable is yield. We are looking for differences in treatment.
  I understand that my repeated measures are nested into the rep, and a simple anova like aov(yield~trt) is not appropriate since it would treat each repeated measure as an independent rep. 
  I think that I have to specify an error term, with date nested in rep, but I'm confused with the syntax.</p>
  
  <p>This is my code</p>
  
  <pre><code>summary(aov(data=yi,yield~trt + Error(rep/date)))  #this means date nested in rep
  </code></pre>
  
  <p>Thank you for all your help!</p>
  
  <p>This is my dataset</p>
  
  <pre><code>structure(list(date = structure(c(17676, 17680, 17683, 17687, 
  17690, 17695, 17698, 17702, 17705, 17709, 17712, 17716, 17719, 
  17723, 17726, 17730, 17733, 17737, 17740, 17744, 17747, 17751, 
  17754, 17759, 17761, 17765, 17768, 17772, 17775, 17779, 17782, 
  17676, 17680, 17683, 17687, 17690, 17695, 17698, 17702, 17705, 
  17709, 17712, 17716, 17719, 17723, 17726, 17730, 17733, 17737, 
  17740, 17744, 17747, 17751, 17754, 17759, 17761, 17765, 17768, 
  17772, 17775, 17779, 17782, 17676, 17680, 17683, 17687, 17690, 
  17695, 17698, 17702, 17705, 17709, 17712, 17716, 17719, 17723, 
  17726, 17730, 17733, 17737, 17740, 17744, 17747, 17751, 17754, 
  17759, 17761, 17765, 17768, 17772, 17775, 17779, 17782, 17676, 
  17680, 17683, 17687, 17690, 17695, 17698, 17702, 17705, 17709, 
  17712, 17716, 17719, 17723, 17726, 17730, 17733, 17737, 17740, 
  17744, 17747, 17751, 17754, 17759, 17761, 17765, 17768, 17772, 
  17775, 17779, 17782, 17676, 17680, 17683, 17687, 17690, 17695, 
  17698, 17702, 17705, 17709, 17712, 17716, 17719, 17723, 17726, 
  17730, 17733, 17737, 17740, 17744, 17747, 17751, 17754, 17759, 
  17761, 17765, 17768, 17772, 17775, 17779, 17782, 17676, 17680, 
  17683, 17687, 17690, 17695, 17698, 17702, 17705, 17709, 17712, 
  17716, 17719, 17723, 17726, 17730, 17733, 17737, 17740, 17744, 
  17747, 17751, 17754, 17759, 17761, 17765, 17768, 17772, 17775, 
  17779, 17782), class = "Date"), yield = c(990, 1560, 1520, 1845, 
  1820, 2260, 1175, 1630, 1305, 2065, 1060, 2060, 1565, 1755, 1380, 
  1875, 1590, 1640, 1185, 1585, 830, 2055, 1285, 2555, 1230, 2095, 
  1565, 1935, 1235, 1510, 1570, 660, 1010, 720, 1370, 1305, 1670, 
  1120, 1780, 1210, 1675, 1600, 1490, 1010, 1060, 985, 1075, 915, 
  1640, 895, 1535, 1330, 1990, 980, 2270, 1135, 1525, 1180, 1020, 
  1010, 1050, 710, 975, 1290, 1115, 785, 1625, 1705, 1235, 1700, 
  1430, 1175, 1115, 1275, 1035, 1085, 1185, 1475, 870, 1580, 845, 
  1560, 635, 2315, 800, 2365, 945, 1515, 1435, 1855, 1355, 1585, 
  1315, 745, 1125, 655, 1085, 1430, 1980, 985, 1675, 1090, 1510, 
  1085, 1730, 1065, 1460, 795, 1345, 1165, 1145, 655, 1310, 645, 
  1780, 945, 2375, 950, 1805, 1760, 1510, 1590, 1515, 1030, 645, 
  1681, 750, 985, 1065, 1350, 875, 1520, 1045, 1800, 1165, 2070, 
  1410, 1435, 1490, 1705, 1230, 1865, 1015, 1740, 745, 1275, 1180, 
  2030, 755, 1540, 1410, 1340, 1155, 1495, 1160, 1335, 1030, 690, 
  1330, 1005, 1240, 1190, 1625, 965, 1565, 1195, 1305, 1180, 1255, 
  1090, 1675, 1250, 1615, 595, 1395, 695, 1600, 1165, 2215, 675, 
  1300, 1190, 1035, 985, 985, 935), trt = c("117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "117 lb/ac Preplant", "117 lb/ac Preplant", "117 lb/ac Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant", "No Preplant", "No Preplant", "No Preplant", "No Preplant", 
  "No Preplant"), rep = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
  1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 
  2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 
  3, 3, 3, 3, 3)), row.names = c(NA, -186L), class = "data.frame")
  </code></pre>