Update R code for png saving

Update R code for png saving