R Programming assignment 4