Initial R Code Tidy Up