latest changes to assignment 1 code to include subsetting in R