solution of R programming assignment