title: How to do In R a loop that calculate mean and median of rows and add it in a data frame
body: <p>I have a data frame with the subjects in the rows and variables in the coloumn, the problem is that there are 40 rows per subjects (because each subjects had 40 trials), so not each rows correspond to each subject.</p>
  
  <p>I want to have a new data frame containing one subjects per row and in the coloumn the mean and the median of some variables.</p>
  
  <p>Unfortunately I'm relatively new to R and to programming languages in genereal in the sense that I never manage a for loop to work, and I guess here I need someting similar.</p>
  
  <p>Can someone suggest some ways to do it?</p>
  
  <p>Here is my data.</p>
  
  <pre><code>    Subject Trial         File    Int   Target    Synchrony     corr_ans Risposta ACC       RT
  8          1     8   sinc2_lab579.wmv ASD   sinc        si              1        5     1       1418
  9          1     9 asinc12_lab612.wmv ASD   asinc       no              0        1     1       1313
  10         1    10  asinc9_lab879.wmv ASD   asinc       no              0        1     1       1460
  11         1    11   asinc3_con13.wmv TD    asinc       no              0        2     1       2330
  12         1    12   sinc11_con13.wmv TD    sinc        si              1        3     0       2003
  13         1    13   sinc4_lab879.wmv ASD   sinc        si              1        5     1       2334
  </code></pre>
  
  <p>Thanks
  Mauro</p>