code from the book "Exploring Everyday Things with R and Ruby"