finished writing R code; needs revision and addition of markdown commentary