Assorted R code