(Nearly) final versions of all three R scripts