Build a Using R

0

Hello, I think my question is quite simple, but come on:

How do I make this look like this:

coef.matrix=matrix(0,4,16)

for (k in c(1,4)){
  for(i in 1:2){
    coef.matrix[i,1]=summary(lm(y ~ x))$coef[2,k]
  }

}

Instead of "from 1 to 4" I would like to include "1 or 4". Can you do this within the parentheses or will I need to call if / else ?

    
asked by anonymous 05.04.2017 / 17:15

1 answer

0

Do this:

for (k in c(1,4)) {
}
    
05.04.2017 / 19:06