implementation of rprogramming assignment 2