final code for rankhospital.R