title: Why my simple code doesn't store the variable in global environment
body: <p>I have a strange issue that the value of the function is supposed to be stored in the global environment. instead, it returns an error for a line that shouldn't be executed!</p>
  
  <pre><code>DEV.OneCancerStrings &lt;- function(Number){
    if(!exists("Number")){
      if(!exists("study_number")){
        study_number &lt;&lt;- 1
        specified_number &lt;- study_number   
      }else if(exists("study_number")){   
        study_number &lt;&lt;- study_number + 1   
        specified_number &lt;- study_number   
      } 
    }else if(exists("Number")){ 
      specified_number &lt;- Number 
    }
  }
  </code></pre>
  
  <p>If I execute it without any argument I see the following error:</p>
  
  <pre><code>DEV.OneCancerStrings()
  Error in DEV.OneCancerStrings() : 
    argument "Number" is missing, with no default
  </code></pre>