R functions to facilitate repetitive analysis