The statistical package R is used to construct several matched samples from one data set. The focus is on the mechanics of using R, not on the design of observational studies. The process is made tangible by describing it in detail, closely inspecting intermediate results; however, essentially, three steps are involved, (i) cre- ating a distance matrix, (ii) adding a propensity score caliper to the distance matrix, and (iii) finding an optimal match. One appendix contains a short introduction to R. A second appendix contains short R functions used to create distance matrices used in matching.
Rosenbaum, P. R. (2010). Chapter 13: Matching in R. In Design of Observational Studies (pp. 237–253). https://doi.org/10.1007/978-1-4419-1213-8