You didn't say what form you wanted the output in, but
here's one way:
sapply(split(dat,dat$individual),function(s)lm(height~time,data=s)$coef)
1 2
(Intercept) 8.466667 19.866667
time 2.485714 -2.057143
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec...@stat.berkeley.edu
On Tue, 2 Nov 2010, Rosario Garcia Gil wrote:
Hello
I would like to extract the estimates for the intercept and slope by individual
for growth from a lm fit.
Any advice?
Individual Time point Height
1 1 10
1 2 11
1 3 23
1 4 15
1 5 21
1 6 23
2 1 24
2 2 12
2 3 9
2 4 10
2 5 11
2 6 10
...
Thanks
______________________________________________
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.
______________________________________________
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.