Edited R scripts to answer assignment