Reformatting class merging double matrix datasets