AnalytixLabs interview question

Some programming questions on R A case study is given to solve