Machine learning is the use of computer algorithms to identify patterns in data and then classify new data according to those patterns. K-Nearest Neighbors (k-NN) is a simple and intuitive algorithm for machine learning. Using just basic algebra, k-NN is a powerful tool for many data classification tasks. The following examples demonstrate how a simple k-NN implementation works to classify colors, identify handwritten digits, and to predict the topics of articles from BBC News. R code for each example is also included.