Please check the resources of this lecture - you will find a PDF file with all the R codes used in the first chapter of the course.