Corrected R script for cluster sampling