towards automating the R code...