Edited R file for class programming assignment2