towards R script on re-sampled