Source: https://maths-people.anu.edu.au/~johnm/courses/dm/rintro/r-tutorials.pdf