switched to data.table instead of data.frame to see if it will compute faster.
progress in using data table with melt and dcast to summarize data