R program assignment

added code and comments