R file edited to show my completed functions