[R] multiple numerical variables in aov

Thomas Lumley tlumley at u.washington.edu
Fri Apr 11 17:26:19 CEST 2003

On Fri, 11 Apr 2003, [iso-8859-1] Rishabh Gupta wrote:

> Hi all,
>  I have a question regarding the anova function aov(). I want to perform an anova calculation
> using one grouping variable but more than one numerical variables:
> So instead of:
>      aov(v ~ g)
> I want something like
>      aov(v1 + v2 + v3 ~ g)

> Essentially I want to find out whether the variables v1, v2, v3, etc can
> collectively discriminate between different values of variable g. Could
> somebody tell whether this is possible and if so how?

help(aov) does say that the formula can specify multiple responses,
though admittedly it doesn't explain how.  You use


However, if you want to find out about whether these variables
collectively discriminate this will not be the right way. You want
something like lda() in the MASS package.

> Also, could somebody please tell me the difference between the aov()
> function and the anova() function. I've been using aov() so far and it
> seems to work fine. Could somebody tell me what the difference is and
> which one is better.

They are both of excellent quality :). They do completely different
things. As their respective help pages say

 Compute analysis of variance (or deviance) tables for one or more
     fitted model objects.

 Fit an analysis of variance model by a call to `lm' for each


More information about the R-help mailing list