R program for I matrix, second assignment