R code for generating iamges