[R] ANOVA with many IV's
Rolf Turner
rolf.turner at xtra.co.nz
Thu Jun 9 07:22:51 CEST 2011
It is not nearly as complicated as Dennis Murphy makes out.
Just do
aov(y ~ ., data=X)
where X is your data frame with one column (the response) name ``y''
and then any number of other columns which will then form the
predictors (which may be either numeric predictors or factors).
cheers,
Rolf Turner
On 09/06/11 16:14, Dennis Murphy wrote:
> Hi:
>
> You can try something like this: assuming the factor variables of
> interest and the response variable are in a data frame named df,
>
> ivset<- c(<comma separated vector of factor names>)
> myaovs<- lapply(ivset, function(x) {
> form<- as.formula(substitute(yvar ~ foo, list(foo = as.name(x))))
> aov(form, data = df)
> } )
>
> This should generate a list of aov objects, one per factor in ivset.
> > From there, R has functions to extract pieces of output as needed.
>
> Since no example data was presented, the above is untested, so caveat emptor.
>
> HTH,
> Dennis
>
> On Wed, Jun 8, 2011 at 3:25 PM, mandakaye<mandakaye at gmail.com> wrote:
>> I'd like to conduct one-way ANOVA's on multiple IV's. Is there a function for
>> "aov (y~"all of my IV's")? Thank you!
>>
>> --
>> View this message in context: http://r.789695.n4.nabble.com/ANOVA-with-many-IV-s-tp3583788p3583788.html
>> Sent from the R help mailing list archive at Nabble.com.
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list