1

I want to do an ANOVA test with my abundance data of different stations, I want to know what is the correct way to write the script because all examples with aov function are related to a formula but I do not be sure that this formula takes account all columns comparing their means.

The following data are a single example of the way that I use to try to do the test. But there are is not a categorical variable in the columns, for this reason, I am sure that this way is wrong.

Thanks for your help

set.seed(200)
D <- data.frame(a=sample(15),b=sample(15), c=sample(15))

A<-aov(a~c, data = D)
  • Can you post sample data? Please edit the question with the output of `dput(df)`. Or, if it is too big with the output of `dput(head(df, 20))`. (`df` is the name of your dataset.) – Rui Barradas May 21 '18 at 19:07

1 Answers1

1

You need first to reshape the data.frame from wide to long format.

The following uses an external package, reshape2, to reshape the data from wide to long format.

molten <- reshape2::melt(D)
head(molten)

model <- lm(value ~ variable, data = molten)
anova(model)
Rui Barradas
  • 70,273
  • 8
  • 34
  • 66