Re: [R-sig-Geo] Variables inside a for

2008-12-01 Thread Roger Bivand
On Mon, 1 Dec 2008, Gabor Grothendieck wrote: Use this: lm(database[c(variable[i], "INCOME")]) On Mon, Dec 1, 2008 at 7:45 PM, Raphael Saldanha <[EMAIL PROTECTED]> wrote: Hi! I had a database with some variables in sequence. Let me say: TX01, TX02, TX03 and TX04. But I need to run some regr

Re: [R-sig-Geo] Variables inside a for

2008-12-01 Thread Frede Aakmann Tøgersen
How about doing something like: x <- 1:100 y1 <- 1 + 2*x + rnorm(x) y2 <- 2 + 3*x + rnorm(x) lm(cbind(y1,y2) ~ x) This is much faster. Yours sincerely / Venlig hilsen Frede Aakmann Tøgersen Statistician, M.Sc., Ph.D. Modeling, Statistics and Risk Analysis Wind and Site Competence Centre T

Re: [R-sig-Geo] Variables inside a for

2008-12-01 Thread Gabor Grothendieck
Use this: lm(database[c(variable[i], "INCOME")]) On Mon, Dec 1, 2008 at 7:45 PM, Raphael Saldanha <[EMAIL PROTECTED]> wrote: > Hi! > > I had a database with some variables in sequence. Let me say: TX01, TX02, > TX03 and TX04. > > But I need to run some regressions changing the variables... so: >

Re: [R-sig-Geo] Variables inside a for

2008-12-01 Thread Fernando Miguez
Hi Raphael, If you truly only need to run 4 regressions you might be less confused if you just do test1 <- lm(TX01 ~ INCOME, data = database) test2 <- lm(TX02 ~ INCOME, data = database) test3 <- lm(TX03 ~ INCOME, data = database) test4 <- lm(TX04 ~ INCOME, data = database) If you need to do t

[R-sig-Geo] Variables inside a for

2008-12-01 Thread Raphael Saldanha
Hi! I had a database with some variables in sequence. Let me say: TX01, TX02, TX03 and TX04. But I need to run some regressions changing the variables... so: variable <- paste("TX0", 1:4, sep="") for(i in 1:4){ test[i] <- lm(variable[i] ~ INCOME, data=database) } But doesn't work... lm tries t