title: Does R have something similar to main function as in python, C?
body: <p>I'm looking for a better way to organize my R code. Ideally I'm hoping to</p>
  
  <ul>
  <li>Put all auxiliary functions at the end of the script. It will help me to focus on the main part of the code without being distracted by lots of helper functions at the beginning of the script. </li>
  <li>Allow each variable to only exist in certain scope. e.g If I accidentally assign values to certain variables, I don't want these variables to be picked up by functions defined later than them and make a mess. </li>
  </ul>
  
  <p>In Python, the two goals can be achieved easily by:</p>
  
  <pre><code>def main():
  ...
  
  def helper_func(x,y):
  ...
  
  if __name__ == '__main__':
      main()
  </code></pre>
  
  <p>Is it possible in R? Any advice on making it similar to this if not possible?</p>