R scripts used for BAEA Project