data cleaning to return rate matrix