map: Plot a choropleth map for an indicator

Description Usage Arguments Value See Also Examples

View source: R/quick_charts.R

Description

Plot a choropleth map for an indicator

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
map(
  data,
  ons_api,
  area_code,
  fill,
  type = "static",
  value,
  name_for_label,
  title = "",
  subtitle = "",
  copyright_size = 4,
  copyright_year = Sys.Date()
)

Arguments

data

data.frame object to plot using ggplot2 functions

ons_api

string; GeoJSON address provided from the ONS geography portal

area_code

field containing area codes to join to shape file imported from ONS API

fill

field to be used to determine the colouring of the areas (unquoted)

type

string; the output map required. Can be "static" or "interactive"

value

field containing variable to be plotted on x axis (unquoted)

name_for_label

if interactive map, name of field containing area names to be used for label (unquoted) - optional

title

string; title of chart

subtitle

string; text to use as subtitle to graph

copyright_size

number; fix the size of the copyright text

copyright_year

number (length 4 characters) or Date class; the copyright year displayed at bottom of the map. Applies to static maps only

Value

a either a static or interactive ggplot choropleth map

See Also

Other quick charts: box_plots(), compare_areas(), compare_indicators(), overview(), population(), trends()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
ons_api <- "https://opendata.arcgis.com/datasets/687f346f5023410ba86615655ff33ca9_4.geojson"

p <- map(mapdata,
         ons_api = ons_api,
         area_code = AreaCode,
         fill = Significance,
         title = "Map example",
         subtitle = "An indicator for Upper Tier Local Authorities England",
         copyright_year = 2019)

p

## For an interactive (leaflet) map
p <- map(mapdata,
         ons_api = ons_api,
         area_code = AreaCode,
         fill = Significance,
         type = "interactive",
         value = Value,
         name_for_label = AreaName,
         title = "An indicator for Upper Tier<br>Local Authorities England")
p
## End(Not run)

fingertipscharts documentation built on July 2, 2020, 2:59 a.m.