+assignment 2 (tested)

added the required 2 functions.
Code working, tested with the one in the beginning comments in the R
file.