I'm looking for a better way to organize my R code. Ideally I'm hoping to
- 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.
- 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.
In Python, the two goals can be achieved easily by:
def main():
...
def helper_func(x,y):
...
if __name__ == '__main__':
main()
Is it possible in R? Any advice on making it similar to this if not possible?