I am working with two datasets in R. Each is a sample from populations of interest. Dataset A contains 352 observations. Dataset B contains 8,000 observations. My objective is to find observations from dataset B that resemble observations from dataset A, determined by a number of specified socioeconomic attributes (i.e., find the nearest neighbors of A in B). The result will be a new, third dataset containing observations from both populations (n=704).

The objective is conceptually rather simple, I think, but I'm unclear from the help documentation for ?knn and extant tutorials how to technically execute this plan. The closest solution I've come across after searching is this Cross Validated question, but it is for SAS; thus, the supposed answer is difficult for me to translate into R.

Any help or suggestions would be most welcome.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.