R programming: second programming assignment example