[R] apply lm() for all the columns of a matrix

Costas Douvis cdouvis at geol.uoa.gr
Wed Apr 9 12:55:08 CEST 2008


Hi all,

My question is not really urgent. I can write a loop and solve the
problem. But I know that I'll be in a similar situation many more times so
it would be useful to find out the answer

Is there a fast way to perform linear fit to all the columns of a matrix?
(or in the one dimension of a multi-dimensional array.) I'm talking about
many single linear fits, not about a multiple fit. I thought that a
combination of apply and lm would do it but I can't make it work

Thank you
Kostas


-- 
Kostas Douvis
PhD Student
University of Athens - Department of Geography and Climatology
Academy of Athens - Research Centre for Atmospheric Physics and Climatology
email: cdouvis at geol.uoa.gr
tel: +30-210-8832048



More information about the R-help mailing list