Measuring customer retention using cohort analysis in R