Solution for R course, programming assignment #2.