Updated cacgematrix.r script