R scripts used in IRRDD V45 Chapter 2