edited R file with solution to Assignment 2