completed R programming assignment 2