• We are pleased to announce that the winner of our Feedback Prize Draw for the Winter 2024-25 session and winning £150 of gift vouchers is Zhao Liang Tay. Congratulations to Zhao Liang. If you fancy winning £150 worth of gift vouchers (from a major UK store) for the Summer 2025 exam sitting for just a few minutes of your time throughout the session, please see our website at https://www.acted.co.uk/further-info.html?pat=feedback#feedback-prize for more information on how you can make sure your name is included in the draw at the end of the session.
  • Please be advised that the SP1, SP5 and SP7 X1 deadline is the 14th July and not the 17th June as first stated. Please accept out apologies for any confusion caused.

Sept. 2022 Paper B - Q4 (v) (a)

Naitik Shah

Keen member
For the question mentioned in the subject, I have used a slightly different approach in comparison to the one produced in the ER. The maximum possible marks for the same question is 6. Do let me know the score that I would obtain using my method.

Answer in the Examiner's Report:
Median<- rep(0,5)
Mean<- rep(0,5)
Var<- rep(0,5)
for(i in 1:5)
{ Median<- median(salary.current[job.type==i] )
Mean<- mean(salary.current[job.type ==i] )
Var<- var(salary.current[job.type ==i] ) }

## Median # 9.180 9.285 9.410 10.160 10.030
## Mean # 9.168571 9.280333 9.440000 10.101333 10.119167
## Var # 0.07471261 0.02906540 0.00320000 0.03128381 0.05988106

My Solution: I have individually figured out the values and then copy-pasted the same.

In addition, I also wanted to understand when and in what situations am I supposed to use the FOR loop.

Thanks & Regards.
 
I'm assuming you just calculated each of them the long-winded way and got the same answers. In which case you would have got the marks - it just would have taken you a lot longer. Hence, a loop would have saved you time.

That's the point of loops - to do the same task repeatedly.

However, the only places where you have to use a loop are clearly indicated in the Core Reading (eg bootstrapping).
 
Back
Top