Updated R Script to complete the Project