MyNixOS website logo
Description

Operations to Ease Data Analyses Specific to Nigeria.

A set of convenience functions as well as geographical/political data about Nigeria, aimed at simplifying work with data and information that are specific to the country.

naijR

An R package on Nigeria and for Nigeria

CRANstatus Codecov testcoverage R buildstatus Lifecycle:stable

The goal of naijR is to make it easier for R users to work with data related to Nigeria.

Usage

Some simple operations

Maps

One of the useful aspects of this package is enabling users to plot country and sub-national geo-spatial maps. Currently, only vector-type graphics are supported. To find out more, read the vignette–accessible from within R as follows:

vignette('nigeria-maps', 'naijR')

Administrative Regions

States

To create a list of all the States of the Nigerian Federation, simply call states().

library(naijR, quietly = TRUE)
ss <- states()
head(ss)
Abia

Adamawa

Akwa Ibom

Anambra

Bauchi

Bayelsa
cat(sprintf("\n...but Nigeria has %i States.", length(ss)))

...but Nigeria has 37 States.

States from a given geo-political zone can also be selected:

states(gpz = "ne")  # i.e. North-East
Adamawa

Bauchi

Borno

Gombe

Taraba

Yobe

For other capabilities of this function, see ?states().

Local Government Areas

This is a basic example that shows how to very quickly fetch the names of Local Government Areas within a given State:

lgas("Imo")
Aboh Mbaise

Ahiazu Mbaise

Ehime Mbano

Ezinihitte

Ideato North

Ideato South

Ihitte/Uboma

Ikeduru

Isiala Mbano

Isu

Mbaitoli

Ngor Okpala

Njaba

Nkwerre

Nwangele

Obowo

Oguta

Ohaji/Egbema

Okigwe

Orlu

Orsu

Oru East

Oru West

Owerri Municipal

Owerri North

Owerri West

Unuimo

To list all the LGAs in Nigeria, call the same function without any parameters:

n <- length(lgas())
sprintf("Nigeria has a total of %i Local Government Areas", n)
[1] "Nigeria has a total of 774 Local Government Areas"

Want to create a function to check how many LGAs a particular State has?

how_many_lgas <- function(state) {
  n <- length(lgas(state))
  cat(state, "State has", n, "LGAs\n")
}

how_many_lgas("Sokoto")
Sokoto State has 23 LGAs

Working with phone numbers

It is common to come across datasets where phone numbers are wrongly entered or misinterpreted by software like MS Excel. The function fix_mobile() helps with this.

fix_mobile("8032000000")
[1] "08032000000"

The function works on vectors; thus an entire column of a table with phone numbers can be quickly processed. Illegible or irreparable numbers are turned into missing values, e.g.

(dat <- data.frame(
  serialno = 1:8,
  phone = c(
    "123456789",
    "0123456789",
    "8000000001",
    "9012345678",
    "07098765432",
    "08123456789",
    "09064321987",
    "O8055577889"
  )
))
  serialno       phone
1        1   123456789
2        2  0123456789
3        3  8000000001
4        4  9012345678
5        5 07098765432
6        6 08123456789
7        7 09064321987
8        8 O8055577889
fix_mobile(dat$phone)
[1] NA            NA            "08000000001" "09012345678" "07098765432"
[6] "08123456789" "09064321987" "08055577889"

Installation

To download and install the current stable version of this package from CRAN:

install.packages("naijR")

The development version can be obtained from GitHub with:

# install.packages("pak")  # if necessary
pak::pkg_install("BroVic/naijR")

Feedback/Contribution

Contributions are welcome and pull requests for R code or documentation will be gladly entertained. For bug reports or feature requests, kindly submit an issue.

Metadata

Version

0.6.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows