finish R Programming exercise 2