title: Making a Variable Constant in a Function in R
body: <p>Is there any way I can define a function in R with a constant determined from a variable? I'm not sure how to say that better so here is an example.</p>
  
  <pre><code>&gt; index&lt;-3
  &gt; f&lt;-function(x){x+index}
  &gt; f(4)
  [1] 7     #Great!
  &gt; index&lt;-20
  &gt; f(4)
  [1] 24   #No! I still want to see 7!
  </code></pre>
  
  <p>Thank you!</p>