tidying of R code