this is the R script for plot figure 2