map_ita_choropleth: Make a choropleth map of Italian provinces

Description Usage Arguments Value

View source: R/viz_functions.R

Description

Create a choropleth map for Italian provinces based on continuous input data by province

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
map_ita_choropleth(
  province_sf,
  region_sf,
  in_data,
  map_field,
  fill_list,
  fill_lims = NULL,
  titles_list = list(),
  fill_type = "continuous",
  show_legend = TRUE,
  labels_dt = NULL,
  save_fp = NULL,
  file_height = 7.25,
  file_width = 6
)

Arguments

province_sf

[sf] Spatial object of provinces. Should have a 'location_code' field that will be matched to data

region_sf

[sf] Spatial object of regions. Will be added as an outline to map

in_data

[data.table] Dataset to be plotted. Should only include one row of data per province

map_field

[char] Field in 'in_data' to be mapped

fill_list

list of fill parameters that should be used, in the format of arguments to the 'scale_fill_<fill_type>'

fill_lims

[numeric, default NULL] Vector of upper and lower values for color scale.

titles_list

[default empty list] list of any titles that should be included, in the format of arguments to the ggplot 'labs' command

fill_type

[optional, default 'continuous'] Scale fill type eg. 'discrete' or 'continuous'

show_legend

Should the legend be featured on the plot?

labels_dt

[optional] Data.table used to label locations on the graph. Should be a data.table containing at least the fields 'label_name', 'x', 'y', 'x1_lseg', 'x2_lseg', 'y1_lseg', 'y2_lseg'

save_fp

[optional, default NULL] if not NULL (the default), saves to file rather than returning an object. If filled, should be a PNG extension

file_height

[optional, default 8] map height in inches

file_width

[optional, default 6] map width in inches

Value

Either returns a ggplot object or, if 'save_fp' is not NULL, saves to file and returns NULL


njhenry/covidemr documentation built on Feb. 2, 2022, 2:31 a.m.