admin_to_num {sae4health} | R Documentation |
Convert Administrative Level String to Numeric Code
Description
This function converts administrative level names (e.g., "National", "Admin-1") into corresponding numerical values.
Usage
admin_to_num(admin_level)
Arguments
admin_level |
A character string representing the administrative level. It can be "National" or "Admin-X" (where X is a positive integer). |
Value
An integer representing the numerical level: - "National" is converted to 0. - "Admin-X" is converted to X as an integer. - Returns NULL if the input is invalid.
Examples
admin_to_num("National") # Returns 0
admin_to_num("Admin-1") # Returns 1
admin_to_num("Admin-2") # Returns 2
admin_to_num("Invalid") # Returns NULL
[Package sae4health version 1.2.3 Index]