combination of data frame columns in regression r : <p><br>
I have a data frame with colnames A, B, C, D with numeric values. I am trying to generate a linear regression model using variables and trying all the possible combination like A, A+B, A+C, B, B+C ....<br>
I am having trouble generating combinations with data frame.</p>

<pre><code>Data frame
DependentVar A B C D 
</code></pre>

<p>I am trying to generate something like this:<br>
Combinations of independent variables like:</p>

<pre><code>var &lt;- A,B,C,D,A+B,A+C,A+D,B+C,B+D,C+D,A+B+C,A+B+D and so on..
for (v in var){
models &lt;- lm (DependentVar ~ eval(parse(text=v)), data=data)
r2 &lt;- append(summary(models)$r.squared)
}
</code></pre>

<p>Output like dataframe:</p>

<pre><code>Variable combination  Model R2    
A                      0.8
B                      0.7
.
.
</code></pre>

<p>and so on
<br>
Any help will be greatly appreciated! </p>
