Skip to content
Back to formatted view

Raw Message

Message-ID: <971536df0812011835k7ac7d6b8y193b51cec281afc7@mail.gmail.com>
Date: 2008-12-02T02:35:13Z
From: Gabor Grothendieck
Subject: Variables inside a for
In-Reply-To: <c85849370812011645k7b9e31d0m7d2cc344749076b0@mail.gmail.com>

Use this:

lm(database[c(variable[i], "INCOME")])

On Mon, Dec 1, 2008 at 7:45 PM, Raphael Saldanha
<saldanha.plangeo at gmail.com> 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="")
>
> 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 at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>