Use vietnamcode package to convert Vietnam’s provincial ID

less than 1 minute read

If you have ever struggled with various coding schemes of Vietnam’s provincial IDs like me, there’s a solution! I wrote the vietnamcode package to convert across all coding schemes, including provincial names with or without diacritics.

The main function is vietnamcode – here’s how flexible it is:

library(vietnamcode)
vietnamcode(c("HCMC", "TP HCM", "Tp. Ho chi Minh"), 
            origin = "province_name", destination = "province_name_diacritics")
## [1] "TP Hồ Chí Minh" "TP Hồ Chí Minh" "TP Hồ Chí Minh"
vietnamcode(c("Bac Kan", "Bắc Kan", "Bac Can", "bac can"),
            origin = "province_name", destination = "pci")
## [1] "54" "54" "54" "54"

The coding schemes supported are:

  • province_name
  • province_name_diacritics
  • enterprise_census (old and new)
  • PCI

If you find any bug, please let me know at my package on github. I hope you find it useful. Thanks to the people behind the package countrycode for inspiration.

Updated:

Leave a Comment