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

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.ac.be
Fri Mar 11 16:36:55 CET 2005


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


----- Original Message ----- 
From: "Christoph Lehmann" <christoph.lehmann at gmx.ch>
To: <r-help at stat.math.ethz.ch>
Sent: Friday, March 11, 2005 4:21 PM
Subject: [R] aov or t-test applied on all variables of a data.frame


> 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 at 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
>




More information about the R-help mailing list