Soultion for Coursera R Programming class -- programming assignment 2