R code to import files and compute the d'