A generic weighted euclidean distance fit calculator for R