B R code for data simulation