Formatted R code for @jalperin's review