Memory efficient clustering in R for large datasets