Update run_analysis.R

Fixed some bugs and added error checking before merging rows and columns