Here you will find daily news and tutorials about R, contributed by over 750 bloggers.
There are many ways to follow us - By e-mail:On Facebook: If you are an R blogger yourself you are invited to add your own R content feed to this site (Non-English R bloggers should add themselves- here)

(This article was first published on SAS and R, and kindly contributed to R-bloggers)

Suppose we need to find the closest pair of observations on some variable x. For example, we might be concerned that some data had been accidentally duplicated. We return the ID’s of the two closest observations, and their distance from each other. In both languages, we’ll first create the data, then sort it, recognizing that the smallest difference must come between two adjacent observations,

Related

To leave a comment for the author, please follow the link and comment on their blog: SAS and R.