On 3/5/2009 7:53 AM, Sueli Rodrigues wrote:
Hello. I have a file with 480 lines but each 6 lines corresponding just
one sample. How can can work out the linear regression to each 6 lines?
I use the model: model=lm(y~x)
mydf - data.frame(X = rnorm(480), Y = rnorm(480))
mydf$SAMPLE - rep(1:80, each=6)
by(mydf, mydf$SAMPLE, function(x){summary(lm(Y ~ X, data = x))})
OR
lapply(split(mydf, mydf$SAMPLE), function(x){summary(lm(Y ~ X, data = x))})
OR
library(nlme)
fm1 - lmList(Y ~ X | SAMPLE, mydf)
summary(fm1)
Sueli Rodrigues
Agronomy Eng. - UNESP
Master Degree - USP/ESALQ
PPG-Soils and Plants Nutrition
Phones(19)93442981
(19)33719762
__
R-help@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.
--
Chuck Cleland, Ph.D.
NDRI, Inc. (www.ndri.org)
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894
__
R-help@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.