Objects for Representing the Local Government Areas (LGAs) of Nigeria
lgas(region = NA_character_, strict = FALSE, warn = TRUE)
is_lga(x)
as_lga(x)
# S3 method for lgas
print(x, ...)
# S3 method for lgas
c(...)
# S3 method for lgas
[[(x, i, exact = TRUE)
# S3 method for lgas
[(x, i)
# S3 method for lgas
na.exclude(object, ...)
Context-dependent. Either State(s) of the Federation
or Local Government Area(s) - internal checks are performed to determine
what applies. In cases where States are synonymous to LGAs, the default
behaviour is to use the State as a basis for selecting the LGAs. This
can be modified with strict
. The default value is
NA_character_
and will return all 774 LGAs.
logical; in the event of a name clash between State/LGA,
return only the specified LGA when this argument is set to TRUE
.
logical; issue a warning when one or more elements are not actually Local Government Areas (or were misspelt).
An object of type character
. This includes higher
dimension object classes like matrix
and array
. For
as_lga
, a string representing a Local Government Area that shares its
name with one of its States.
Arguments used for methods. See documentation of generic for details.
See help file for ?Extract
An object of class regions
If length of ng.state
== 1L, a character vector containing
the names of Local Government Areas; otherwise a named list, whose elements
are character vectors of the LGAs in each state.
is_lga
returms a vector the same length as the input object
(each element that is not a valid Local Government Area will evaluate to
FALSE
); with as_lga
, an object of class lgas
.
There are six (6) LGAs that share names with their State - Bauchi, Ebonyi, Gombe, Katsina, Kogi and Ekiti.
how_many_lgas <- function(state) {
require(naijR)
stopifnot(all(is_state(state)))
cat(sprintf("No. of LGAs in %s State:", state),
length(lgas(state)),
fill = TRUE)
}
how_many_lgas("Sokoto")
#> No. of LGAs in Sokoto State: 23
how_many_lgas("Ekiti")
#> No. of LGAs in Ekiti State: 16
is_lga(c("Pankshen", "Pankshin"))
#> [1] FALSE TRUE
# With coercion
kt.st <- states("Katsina") # Ensure this is a State, not an LGA.
kt.lg <- suppressWarnings(as_lga(kt.st))
is_state(kt.st) # TRUE
#> [1] TRUE
is_lga(kt.lg) # TRUE
#> [1] TRUE
## Where there's no ambiguity, it doesn't make sense to coerce
## This kind of operation ends with an error
if (FALSE) {
as_state("Kano")
as_lga("Michika")
}