R code for Coolmore blog