1

I am not too familiar with using R for stats, but I really need to be able to analyze my data. I am comparing the level of a compound found in plants from two different locations, and within each location there were sites next to trails and far from trails. I also need to look at soil pH as a covariant. So I want to compare the effects of location and trail adjacency on compound level with pH as a covariate. I am wondering if I have this set up correctly in R and if I should be using + or *.

mod = aov(compound_lvl ~ pH + location*trail_adjacency, data=d,
contrasts=list(location=contr.sum, trail_adjacency=contr.sum))
Anova(mod)


nyrun
  • 11
  • 1

1 Answers1

1

I typed in "R ANCOVA" in google and the literary first result answers your question. Have a look here. If you are interested hpw the output relates to the output of lm you can read it here.

To put it short, you can use aov or lm. You have to pay attention for categorical variables which must not be of class numeric but factors. You can use dummy or contrast coding. Using + adds the main effects while using * in the formula adds main effects and the interaction of the variables. Further, you can also use : if you want to include only the interaction