create R code and generate png file