R Tutorial: Distance metrics