Learn R Programming

naijR (version 0.3.2)

map_ng: Map of Nigeria

Description

Maps of the Federal Republic of Nigeria that are based on the basic plotting idiom utilised by maps:map and its variants.

Usage

map_ng(
  region = character(),
  data = NULL,
  x = NULL,
  y = NULL,
  breaks = NULL,
  categories = NULL,
  title = NULL,
  caption = NULL,
  show.neighbours = FALSE,
  show.text = FALSE,
  leg.x = 13L,
  leg.y = 7L,
  leg.title,
  leg.orient = c("vertical", "horizontal"),
  ...
)

Arguments

region

A character vector of regions to be displayed. This could be States or Local Government Areas.

data

An object containing data, principally the variables required to plot in a map.

x, y

Numeric object or factor (or coercible to one). See Details.

breaks

Numeric. A vector of length >= 1. If a single value i.e. scalar, it denotes the expected number of breaks. Internally, the function will attempt to compute appropriate category sizes or fail if out-of bounds. Where length is >= 3L, it is expected to be an arithmetic sequence that represents category bounds as for cut (applicable only to choropleth maps).

categories

The legend for the choropleth-plotted categories. If not defined, internally created labels are used.

title, caption

An optional string for annotating the map.

show.neighbours

Logical; TRUE to display the immediate vicinity neighbouring regions/countries.

show.text

Logical. Whether to display the labels of regions.

leg.x, leg.y

Numeric. Position of the legend.

leg.title

String. The legend Title

leg.orient

The orientation of the legend i.e. whether horizontal or vertical.

...

Further arguments passed to map

Value

An object of class maps containing the data used to draw the map and which can be used for additional calls to map or other similar functions (e.g. graphics::plot.default).

Details

The default value for region is to print all State boundaries. data enables the extraction of data for plotting from an object of class data.frame. Columns containing States are identified. The argument also provides context for quasiquotation when providing the x and y arguments.

For x and y, when both arguments are supplied, they are taken to be point coordinates, where x represent longitude and y latitude. If only x is supplied, it is assumed that the intention of the user is to make a choropleth map, and thus, numeric vector arguments are converted into factors i.e. number classes. Otherwise factors or any object that can be coerced to a factor should be used.

For plain plots, the col argument works the same as with map. For choropleth maps, the colour provided represents a (sequential) colour palette based on RColorBrewer::brewer.pal. The available colour options can be checked with getOption("choropleth.colours") and this can also be modified by the user.

Examples

Run this code
# NOT RUN {
map_ng() # Draw a map with default settings
map_ng(states("sw"))
map_ng("Kano")
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab