CAT algorithms in R