Skip to contents

This function shortens the region names in a PSGC data frame.

Usage

shorten_region_name(data, which = c("label", "number"), col = "area_name")

Arguments

data

A data frame containing PSGC data.

which

Character. Specifies whether to shorten the region name by label or number. Options are "label" or "number".

col

Character. The name of the column containing the area names. Default is "area_name".

Value

A data frame with the region names shortened based on the specified which argument.

Examples

regions <- get_psgc(level = "regions")
shorten_region_name(regions)
#> # A tibble: 18 × 3
#>    area_code  area_code_old area_name          
#>    <chr>      <chr>         <chr>              
#>  1 0100000000 010000000     Ilocos Region      
#>  2 0200000000 020000000     Cagayan Valley     
#>  3 0300000000 030000000     Central Luzon      
#>  4 0400000000 040000000     CALABARZON         
#>  5 0500000000 050000000     Bicol Region       
#>  6 0600000000 060000000     Western Visayas    
#>  7 0700000000 070000000     Central Visayas    
#>  8 0800000000 080000000     Eastern Visayas    
#>  9 0900000000 090000000     Zamboanga Peninsula
#> 10 1000000000 100000000     Northern Mindanao  
#> 11 1100000000 110000000     Davao Region       
#> 12 1200000000 120000000     SOCCSKSARGEN       
#> 13 1300000000 130000000     NCR                
#> 14 1400000000 140000000     CAR                
#> 15 1600000000 160000000     Caraga             
#> 16 1700000000 170000000     MIMAROPA Region    
#> 17 1800000000 NA            NIR                
#> 18 1900000000 150000000     BARMM              
shorten_region_name(regions, which = "number")
#> # A tibble: 18 × 3
#>    area_code  area_code_old area_name
#>    <chr>      <chr>         <chr>    
#>  1 0100000000 010000000     I        
#>  2 0200000000 020000000     II       
#>  3 0300000000 030000000     III      
#>  4 0400000000 040000000     IV-A     
#>  5 0500000000 050000000     V        
#>  6 0600000000 060000000     VI       
#>  7 0700000000 070000000     VII      
#>  8 0800000000 080000000     VIII     
#>  9 0900000000 090000000     IX       
#> 10 1000000000 100000000     X        
#> 11 1100000000 110000000     XI       
#> 12 1200000000 120000000     XII      
#> 13 1300000000 130000000     NCR      
#> 14 1400000000 140000000     CAR      
#> 15 1600000000 160000000     XIII     
#> 16 1700000000 170000000     MIMAROPA 
#> 17 1800000000 NA            NIR      
#> 18 1900000000 150000000     BARMM