R scripts for future reference