General R scripts for use