Running examples in 'simPop-Ex.R' failed
The error most likely occurred in:

> ### Name: simInitSpatial
> ### Title: Generation of smaller regions given an existing spatial variable
> ###   and a table.
> ### Aliases: simInitSpatial
> ### Keywords: manip
> 
> ### ** Examples
> 
> data(eusilcS)
> data(eusilcP)
> 
> # no districts are available in the population, so we have to generate those
> # we randomly assign districts within "region" in the eusilc population data
> # each hh has the same district
> simulate_districts <- function(inp) {
+   hhid <- "hid"
+   region <- "region"
+ 
+   a <- inp[!duplicated(inp[,hhid]),c(hhid, region)]
+   spl <- split(a, a[,region])
+   regions <- unique(inp[,region])
+ 
+   tmpres <- lapply(1:length(spl), function(x) {
+     codes <- paste(x, 1:sample(3:9,1), sep="")
+     spl[[x]]$district <- sample(codes, nrow(spl[[x]]), replace=TRUE)
+     spl[[x]]
+   })
+   tmpres <- do.call("rbind", tmpres)
+   tmpres <- tmpres[,-c(2)]
+   out <- merge(inp, tmpres, by.x=c(hhid), by.y=hhid, all.x=TRUE)
+   invisible(out)
+ }
> 
> eusilcP <- simulate_districts(eusilcP)
> table(eusilcP$district)

  11   12   13   14   21   22   23   24   25   26   27   28   29   31   32   33 
 442  514  483  502 1329 1175 1213 1329 1183 1136 1106 1290 1366 1995 1929 1905 
  34   35   36   41   42   43   44   45   46   47   48   49   51   52   53   54 
1928 1947 1953  464  447  526  421  463  466  405  427  492 1590 1635 1662 1643 
  55   61   62   63   64   65   66   71   72   73   74   75   76   77   78   81 
1612 1758 1670 1744 1700 1763 1675  546  530  472  471  445  490  567  504  629 
  82   83   84   85   86   87   88   89   91   92   93 
 465  600  529  528  546  455  505  539  870  857  818 
> 
> # we generate a synthetic population
> inp <- specifyInput(data=eusilcS, hhid="db030", hhsize="hsize", strata="db040", weight="db090")
> simPopObj <- simStructure(data=inp, method="direct", basicHHvars=c("age", "rb090"))
> 
> # we generate the input table using the broad region (variable 'region')
> # and the districts, we have generated before.
> # we
> tab <- as.data.frame(xtabs(rep(1, nrow(eusilcP)) ~ eusilcP$region + eusilcP$district))
> colnames(tab) <- c("db040", "district", "Freq")
> 
> simPopObj <- simInitSpatial(simPopObj, additional="district", region="db040", tspatial=tab)
Error in sample.int(length(x), size, replace, prob) : 
  NA in probability vector
Calls: simInitSpatial ... sample -> [ -> [.factor -> NextMethod -> sample.int
Execution halted