I'd use the k-means algorithmclustering (with k = n) to find the n centroids and use these centroids as the set R.
k-means minimizes the expected L2 distance (i.e. $|x-c|^2$, not $|x-c|$, in case that's important -- in many cases it's not) between a point and its centroid. If all of your new testing points are in the training set, then the ideal distance (in S) would be 0, and the new distance (in R given by the centroids) will be minimized by k-means. If your testing points are different from the training points, but come from the same distribution, then this will minimize an upper bound on the distance.
I'd use the k-means algorithm (with k = n) to find the n centroids and use these centroids as the set R. There'seven
k-meansminimizestheexpectedL2distance(i.e.$|x-c|^2$,not$|x-c|$,incasethat'simportant--inmanycasesit'snot)between a chancethiswillminimizesomethingpointanditscentroid.Ifallofyournewtestingpointsareinthetrainingset,thentheidealdistance (maybeinS)wouldbe0,and the discrepancynewdistance(in L2norm)Rgivenbythecentroids)willbeminimizedbyk-means.Ifyourtestingpointsaredifferentfromthetrainingpoints, althoughI'mnotsurebutcomefromthesamedistribution,thenthiswillminimizeanupperboundonthedistance.
I'd use the k-means algorithm (with k = n) to find the n centroids and use these centroids as the set R. There's even a chance this will minimize something (maybe the discrepancy in L2 norm), although I'm not sure.