r programming assignment2 completed functions.