library(StatMatch)
## Loading required package: proxy
## 
## Attaching package: 'proxy'
## 
## The following objects are masked from 'package:stats':
## 
##     as.dist, dist
## 
## Loading required package: clue
## Loading required package: survey
## Loading required package: grid
## 
## Attaching package: 'survey'
## 
## The following object is masked from 'package:graphics':
## 
##     dotchart
## 
## Loading required package: RANN
YL <- 3
ZL <- 100

a <- data.frame(x="a", y=runif(YL))
b <- data.frame(x="a", y=runif(ZL))

tryCatch(
  RANDwNND.hotdeck(a, b, match.vars = "y", don.class = "x", dist.fun = "ANN", cut.don="exact", k=20),
  error = print
)
## <simpleError in nn2(data = x.rec, query = x.don, k = k0, ...): Cannot find more nearest neighbours than there are points>
sessionInfo()
## R version 3.1.2 (2014-10-31)
## Platform: x86_64-pc-linux-gnu (64-bit)
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=de_CH.UTF-8        LC_COLLATE=en_US.UTF-8    
##  [5] LC_MONETARY=de_CH.UTF-8    LC_MESSAGES=en_US.UTF-8   
##  [7] LC_PAPER=de_CH.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] grid      stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
## [1] StatMatch_1.2.2 RANN_2.4.1      survey_3.30-3   clue_0.3-48    
## [5] proxy_0.4-13   
## 
## loaded via a namespace (and not attached):
##  [1] cluster_1.15.3  digest_0.6.8    evaluate_0.5.6  formatR_1.0.3  
##  [5] htmltools_0.2.6 knitr_1.8.15    rmarkdown_0.4.2 stringr_0.6.2  
##  [9] tools_3.1.2     ulimit_0.0-2