added warning for factors to be same length as nrow(mat)