Looks up the nearest hospital for a given zipcode (4 digits) based on the shortest distance in the postcodes4_afstanden dataset.
adherence_area(zipcode)A character or numeric vector of zipcodes. Six-character
zipcodes are automatically truncated to the first 4 digits using
substr().
A character vector of hospital names, the same length as zipcode.
The function looks up the distance from each input zipcode to all hospital zipcodes in postcodes4_afstanden. The hospital with the shortest distance is returned. In case of equal distances, the first hospital in definition order is chosen.
The following hospitals and their zipcodes are hard-coded:
| Hospital | Zip Code |
| Antonius | 8601 |
| Frisius Heerenveen | 8441 |
| Frisius Leeuwarden | 8934 |
| Martini | 9728 |
| Nij Smellinghe | 9202 |
| Ommelander | 9679 |
| Treant | 7824 |
| Wilhelmina | 9401 |
Zipcodes not found in postcodes4_afstanden return NA.
adherence_area("9700")
#> [1] NA
adherence_area(c("9713", "7702", "8896"))
#> [1] "Martini" "Treant" "Frisius Leeuwarden"
# six-character zipcodes are automatically truncated
adherence_area("9251AB")
#> [1] "Frisius Leeuwarden"