How to run linear regression on a dataset, taking each time a single variable as the dependent variable?
<p>I have a dataset having all numeric variables called 'dt'.. want to take each single variable as dependent variable and find the best combination of the remaining predictor variables using step wise regression.. and if the resulting "best combination" gives an adjusted R^2 >0.70, output it to the console.. HEre's my naive attempt at doing it.</p>

<pre><code>for(i in ncol(dt)){
    nul&lt;-lm(dt[,i]~1,data=dt)
    ful&lt;-lm(dt[,i]~.,data=dt)
    model&lt;-step(nul,scope = list(lower=nul,upper=ful),direction="forward",trace=FALSE)
    if((summary(lm(as.formula(model$call),data=dt)))$adj.r.squared&gt;0.70){
        print(as.formula(model$call))
        cat(paste("\n"))
    }
}
</code></pre>

<p>Here's the undesired output which I am getting:</p>

<pre><code>dt[, i] ~ Y

Warning messages:
1: attempting model selection on an essentially perfect fit is nonsense 
2: In summary.lm(lm(as.formula(model$call), data = dt)) :
essentially perfect fit: summary may be unreliable
</code></pre>