R programming Assignment 1, actual functions