The questions is attached in the file using R plot to answer and doing code program