Implemented R scripts for Problem #2

Implemented R scripts for Problem #2