Programming assignment 3 for the R-course