Please follow the steps on the screenshots then write the code in the R file