title: Changing the arguments of this function to abstract variables in R
body: <p>In order to use the <em>for</em> loop, I'm trying to replace the arguments in this function by variables:</p>
  
  <pre><code>lm(mpg~cylinders, data=Auto)
  </code></pre>
  
  <p>So I did this:</p>
  
  <pre><code>var1='cylinders'
  
  lm((paste('mpg ~',var1)), data = Auto)
  </code></pre>
  
  <p>It worked fine. </p>
  
  <p>Now, I wonder how we can replace the arguments cylinders+acceleration by var1 and var2.</p>
  
  <p>So tried the same method. I tried to replace this:</p>
  
  <pre><code>lm(mpg~cylinders+acceleration, data=Auto)
  </code></pre>
  
  <p>by </p>
  
  <pre><code>var1='cylinders'
  var2 = 'acceleration'
  
  lm((paste('mpg ~',var1+var2)), data = Auto)
  </code></pre>
  
  <p>But I got a message error:</p>
  
  <pre><code>Error in var1 + var2 : non-numeric argument to binary operator
  </code></pre>
  
  <p>So I want to learn how I can work with var1 and var2 in order to use <em>for</em> loop afterwards.</p>