written R code