Using R to extract DDI from various data formats