Skip to content
Back to formatted view

Raw Message

Message-ID: <43A285B2.7000003@cirad.fr>
Date: 2005-12-16T09:15:30Z
From: Jacques VESLOT
Subject: Help with data.frame and lapply
In-Reply-To: <43A27BD2.1000802@iic.uam.es>

d <- data.frame(x1 = rnorm(100), x2 = rnorm(100), x3 = rnorm(100), cls = 
rnorm(100))
dd <- subset(d, sel=-cls)
lapply(paste("lm(cls ~", names(dd), ",data=d)"), function(x) 
eval(parse(text=x)))


Juan Daniel L??pez Serna a ??crit :

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Hello:
>	I'm having problems with this line of code:
>
>X.lm <- lapply(names(d), function(x) lm(d["cls"] ~ d[x], data=d))
>
>	d[x] is what is giving trouble here, but I don't know exactly how to
>solve it. What I'm trying to do is to create a linear model from each
>column of the data frame 'd' to apply ANOVA later.
>	Thanks very much in advance. Regards:
>
>
>Juan Daniel L??pez Serna
>
>- ----
>Instituto de Ingenier??a del Conocimiento
>(http://www.iic.uam.es)
>Universidad Aut??noma de Madrid
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.2.6 (GNU/Linux)
>Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
>
>iD8DBQFDonvRXHsVbn2qIYMRAqi8AJ0X6zOAevAGzMczQ+ahHlVJnUK4ZQCeIDi6
>PPB3baK8JNOa3eoIgbmVCdM=
>=WKlt
>-----END PGP SIGNATURE-----
>
>______________________________________________
>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
>
>  
>