I have a methylation table with patients in rows and genes in columns.
I want to calculate the average methylation of each gene for each group:
tapply(dfX$gene1, dfX$status, mean)
in the second method, I use aggregate to calculate mean for all genes:
resume <- aggregate(data=dfX, .~status, mean)
 0.05448438 0.05161707 for group 1 and 2 respectively
As you can see, these are two different average results !!
I check and I found that the first method give the right result !
Could you explain me why the function aggregate don't give the good results or if I made a mistake with this function
thanks in advance