R Assignment2 for Dr Peng