R script final version commented