title: Declare a variable within a function to be used outside the function (but not declare globally)
body: <p>If you want to declare a new variable within a function <code>g</code>, I know you can use <code>&lt;&lt;-</code> to declare it as Global variable.</p>
  
  <pre><code>g=function(t){
   a&lt;&lt;-t
  }
  g(0)
  print(a)
  #It gives "0"
  </code></pre>
  
  <p>What if the function <code>g</code> is already within another function <code>f</code>, and you want your function <code>g</code> to declare a new variable within the function <code>f</code> but not globally?</p>
  
  <pre><code>g=function(t){
     #declare the variable a and assign it the value t   
   }
  f=function(t){
     g(t)
     return(a)
  }
  f(0)
  #It should give 0.
  print(a)
  #It should say that the variable a is unknown.
  </code></pre>