Completeting R programming assignment