Code and tests from the book An Introduction to Statistical Learning with Applications in R