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 regressions changing the variables... so:
variable <- paste("TX0", 1:4, sep="")
Or:
lm(as.formula(paste(variable[i], "~ INCOME")), data=database)
as in:
lm(as.formula("dist ~ speed"), data=cars)
Please never cross-post. This should either go to r-help or r-sig-geo, not
both!! Most r-help subscribers are not subscribed to r-sig-geo, so get a
post rejection if they reply. In addition, the topic is really an r-help
question.
Roger
for(i in 1:4){
test[i] <- lm(variable[i] ~ INCOME, data=database)
}
But doesn't work... lm tries to find a variable inside database named
variable[i] ...
Suggestions?
King regards!
Raphael Saldanha
Brasil
[[alternative HTML version deleted]]
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: [EMAIL PROTECTED]
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo