R Programming Solution for STAT500 Applied Statistics