Skip to content
Prev 301950 / 398506 Next

help with a regression problem

Hi,

On Wed, Aug 1, 2012 at 9:06 AM, R Heberto Ghezzo, Dr
<heberto.ghezzo at mcgill.ca> wrote:
You could do it as a one-liner, but it's a lot more understandable if
you write your own function.

myfun <- function(a) {
   x1 <- a[2:5]
   y1 <- a[6:9]
   lm(y1 ~ x1)$coef[2]
}

Then you can pass that function to apply:
sl <- apply(aa,1,myfun)


Sarah