title: How to view the nearest neighbors in R?
body: <p>Let me start by saying I have no experience with R, KNN or data science in general.  I recently found <a href="http://kaggle.com" rel="noreferrer">Kaggle</a> and have been playing around with the <a href="http://www.kaggle.com/c/digit-recognizer" rel="noreferrer">Digit Recognition</a> competition/tutorial.</p>
  
  <p>In this tutorial they provide some sample code to get you started with a basic submission:</p>
  
  <pre><code># makes the KNN submission
  
  library(FNN)
  
  train &lt;- read.csv("c:/Development/data/digits/train.csv", header=TRUE)
  test &lt;- read.csv("c:/Development/data/digits/test.csv", header=TRUE)
  
  labels &lt;- train[,1]
  train &lt;- train[,-1]
  
  results &lt;- (0:9)[knn(train, test, labels, k = 10, algorithm="cover_tree")]
  
  write(results, file="knn_benchmark.csv", ncolumns=1) 
  </code></pre>
  
  <p>My questions are:</p>
  
  <ol>
  <li>How can I view the nearest neighbors that have been selected for a
  particular test row?</li>
  <li>How can I modify which of those ten is selected
  for my <code>results</code>?</li>
  </ol>
  
  <p>These questions may be too broad.  If so, I would welcome any links that could point me down the right road.</p>
  
  <p>It is <strong>very</strong> possible that I have said something that doesn't make sense here.  If this is the case, please correct me.</p>