R coursera Assignment 2- cache matrix