I have data looking like:
Sample Replication Days
1 1 10
1 1 14
1 1 13
2 1 NA
2 1 5
2 1 18
1 2 16
1 2 NA
1 2 18
2 2 15
2 2 7
2 2 12
I want to add a column for the average values of Samples across the replications. I want to keep replication as a factor to see if there is any effect because of replication. For example, an average of Sample 1 for replication 1 and an average of Sample 1 for replication 2 separately. Then I want to use that column for ANOVA using:
sample_aov <- aov(Sample~Days, na.rm=TRUE)
I tried using aggregate but I think I am making a mistake. I will appreciate any help. Thanks!