added code for the second programming assignment for R Programming