Functions edited to complete R Programming - Programming Assignment 2