best attempt at nearest neighbor

Close, but not quite finished. Got a neighbor from the test data for each item in the training data, but need to then predict a label. Unsure of accuracy of the other work, as a certain value seemed to crop up more often than made sense.
We haven't talked about this yet, but you'll generally want to split randomly, which you can do with the sample function. With the iris data set, it happens that the rows are sorted by label (50 setosa, then 50 versicolor, then 50 virginica). So by splitting into top half (training) and bottom half (testing), setosa will be overrepresented in your predictions and virginia will never be predicted!