I am unable to replicate an example from the book "Hands-on Programming with R". I have literally cut / copied the code from the book, but it simply won\'t work.