added r code per grading requirements
added r code