Update run_analysis.R

Improving code structure through functions