Skip to contents

Retrieve states or districts using codes

Usage

code_info(code11, sortAndRemoveDuplicates = FALSE)

# S3 method for class 'numeric'
code_info(code11, sortAndRemoveDuplicates = FALSE)

# S3 method for class 'character'
code_info(code11, sortAndRemoveDuplicates = FALSE)

Arguments

code11

A one to three digit, either numeric or character, vector of odes for which to look up states or districts. States have a two digit code and districts have a five digit code (where the first 2 numbers pertain to the state).

sortAndRemoveDuplicates

Whether or not to sort the output and remove duplicates. By default, the output will be returned in the order of the values provided to the codes parameter. Set this parameter to TRUE to return the output sorted by codes with a single instance of each code.

Value

A data frame with the states or counties and the associated codes.

If `codes` is omitted, the data frame containing all available states is returned.

See also

[codes()]

Examples

code_info(2)
#>   abbr code           stname
#> 1   HP   02 Himachal Pradesh
code_info("02")
#>   abbr code           stname
#> 1   HP   02 Himachal Pradesh
code_info(c("02", "03", "04"))
#>   abbr code           stname
#> 1   HP   02 Himachal Pradesh
#> 2   PB   03           Punjab
#> 3   CH   04       Chandigarh

code_info(19335)
#>        stname abbr          dtname  code
#> 1 West Bengal   WB Purba Bardhaman 19335
code_info(c("19335", "19337"), sortAndRemoveDuplicates = TRUE)
#> # A tibble: 2 × 4
#>   stname      abbr  dtname                    code 
#>   <chr>       <chr> <chr>                     <chr>
#> 1 West Bengal WB    North Twenty Four Pargan* 19337
#> 2 West Bengal WB    Purba Bardhaman           19335