assignment 2.2

completed functions for R programming assignment 2