Andy moved sampling code to working r file