Updated R file with solution for programming assignement 2