Programming assignment 2 on R course at Johns Hopkins University