Re: [R] aov or t-test applied on all variables of a data.frame

From: Dimitris Rizopoulos <dimitris.rizopoulos_at_med.kuleuven.ac.be>
Date: Sat 12 Mar 2005 - 02:36:55 EST

you mean something like this:

dat <- data.frame(matrix(rnorm(10*100), 100), f=sample(letters[1:3], 100, TRUE))
models <- lapply(dat[sapply(dat, is.numeric)], function(x, f) aov(x~f), f=dat$f)

#################

models
lapply(models, summary)

I hope it helps.

Best,
Dimitris



Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium

Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


> Hi
> I have a data.frame with say 10 continuous variables and one
> grouping factor (say 3 levels)
>
> how can I easily (without loops) apply for each continous variable
> e.g. an aov, with the grouping factor as my factor (or if the
> grouping factor has 2 levels, eg. a t-test)
>
> thanks for a hint
>
> cheers
>
> christoph
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Mar 14 10:33:57 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:46 EST