complete R script