Skip to contents

Format scope

Usage

format_scope(
  x,
  type = c("file", "insee"),
  scope = c("department", "region"),
  origin = c("department", "commune"),
  check = TRUE
)

Arguments

x

vector of scopes.

type

character, either file or something else.

scope

character, either department or region.

origin

character, either department or commune.

check

logical, should check occurs.

Value

character of formatted scopes

Author

Frédéric Grelot

Examples

format_scope(1:10)
#>  [1] "D001" "D002" "D003" "D004" "D005" "D006" "D007" "D008" "D009" "D010"
format_scope(1:10, "insee")
#>  [1] "01" "02" "03" "04" "05" "06" "07" "08" "09" "10"
format_scope(1:10, scope = "region")
#>  [1] "R01" "R02" "R03" "R04" NA    "R06" NA    NA    NA    NA   
format_scope(1:10, scope = "region", check = FALSE)
#>  [1] "R01" "R02" "R03" "R04" "R05" "R06" "R07" "R08" "R09" "R10"
format_scope(1:10, "insee", scope = "region")
#>  [1] "01" "02" "03" "04" NA   "06" NA   NA   NA   NA  
format_scope(c("FR", 1:10), "insee", scope = "region")
#>  [1] NA   "01" "02" "03" "04" NA   "06" NA   NA   NA   NA  
format_scope(c(1:10, "2A", "002B"))
#>  [1] "D001" "D002" "D003" "D004" "D005" "D006" "D007" "D008" "D009" "D010"
#> [11] "D02A" "D02B"
format_scope(c(1:10, "2A", "002B"), "insee")
#>  [1] "01" "02" "03" "04" "05" "06" "07" "08" "09" "10" "2A" "2B"
format_scope("R94", "insee", "region")
#> [1] "94"
commune = c("01125", "2A123", "97223", "97723")
format_scope(commune, "insee", "department", "commune")
#> [1] "01"  "2A"  "972" NA