working R script