Edits to R code