a two function R script that can rebin a matrix of values and plot a heat map