solution to assignment 2 r programming course