Working on R implementation for exercise 03