Format Employer Identification Numbers (EINs)
format_ein.RdConverts between numeric EINs (e.g., "123456789") and standardized
ID-style EINs (e.g., "EIN-12-3456789").
This utility ensures EINs are properly zero-padded to nine digits and formatted consistently for joining or matching across datasets.
Examples
# Convert to EIN ID format
format_ein(c("123456789", "987654321"), to = "id")
#> [1] "EIN-12-3456789" "EIN-98-7654321"
#> [1] "EIN-12-3456789" "EIN-98-7654321"
# Convert back to numeric-only
format_ein(c("EIN-12-3456789", "EIN-98-7654321"), to = "n")
#> [1] "123456789" "987654321"
#> [1] "123456789" "987654321"