I have a data set where the samples are grouped by column. The following sample dataset is similar to my data's format:
a = c(1,3,4,6,8)
b = c(3,6,8,3,6)
c = c(2,1,4,3,6)
d = c(2,2,3,3,4)
mydata = data.frame(cbind(a,b,c,d))
When I perform a single factor ANOVA in Excel using the above dataset, I get the following results:
I know a typical format in R is as follows:
group measurement
a 1
a 3
a 4
. .
. .
. .
d 4
And the command to perform ANOVA in R would be to use aov(group~measurement, data = mydata)
. How do I perform single factor ANOVA in R with samples organized by column rather than by row? In other words, how do I duplicate the excel results using R? Many thanks for the help.