How can I resolve the following dimension mismatch with R's K nearest neighbors?

In the code below, I am trying to use K nearest neighbors with a single predictor. To the best of my understanding, there's no need for the number of examples in train.X to match the number of exa...