my attempt at assignment 2 of Johns Hopkins courseras R Programming course