JBean's submission for R assignment 2 - Version 4