incomplete 1NN attempt

This is a rather terrible 1NN attempt; I basically ran out of time here.  My major issue now was trying to figure out a way to calculate the distances for each of the observations -- my instinct was to just create new columns for distances to each of the points and then sort them, but that seems like a bit of a disaster to keep track of everything.
I think there might be a misplaced or extra } here!