R Programming assignment 3