Created RStudio project.
Changed indentation from 2 to 4 spaces.
Refactored code and added comment