Source: https://sites.ualberta.ca/~ahamann/teaching/renr690/materials/r-cheat.pdf