Skip to contents

Intelligently formats identifiers based on their detected type. For numeric IDs that appear to be FIPS codes (1-5 digits), applies zero-padding to 5 digits. For other formats (alphanumeric, longer codes, etc.), converts to character strings without modification.

Usage

format_ids_func(data_frame, id_col)

Arguments

data_frame

Data frame to format

id_col

Column name for the identifier column

Value

Data frame with formatted identifiers as character strings

Details

The function uses the following logic:

  • If all non-NA values are numeric and <= 99999, applies 5-digit zero-padding (typical for county FIPS codes)

  • If values are already character strings or contain non-numeric values, converts to character without modification

  • NA values are preserved as NA