Learn R Programming

GADMTools (version 3.9-1)

dotDensity: Multivariate Dot-Density maps

Description

A dot-density map is one way to map aggregated spatial data without some of the distortions inherent in choropleths.

Usage

dotDensity(map, data, adm.join  = NULL, values = NULL,
                            cases.by.dots = 100, dot.size = .25, labels = NULL,
                            palette   = NULL, title = NULL, subtitle  = NULL,
                            caption   = NULL)

Arguments

map

Object gadm_sf

data

data.frame - data to plot

values

String - the names of the columns in the data.frame we want to plot. (eg: number of cases)

cases.by.dots

integer of breaks values

dot.size

numericr - size of dots. Default = 0.25.

adm.join

String - the name in your dataset joined with the field NAME_X of the map, where X is the level of the administrative boundaries. For instance if the level is about 'Districts' of a country, and your dataset has a field named "Study_Location" containing a list of districts, just do adm.join = "Study_Location".

labels

String vector labels for the legend. Default NULL. If NULL values are used as labels

palette

String - An RColorBrewer palette name or a String vector vector of colors. Default NULL.

title

String - title of the plot. Default is NULL

subtitle

String - subtitle of the plot. Default is NULL.

caption

String - caption of the plot. Default is NULL.

Value

Object ggplot2

Details

----

References

https://en.wikipedia.org/wiki/Dot_distribution_map

See Also

classIntervals

Examples

Run this code
# NOT RUN {
library(GADMTools)
data("Corsica")

# Creates test data.frame (fake data) --------------------------------------
# --------------------------------------------------------------------------
VAR_1 <- as.integer(runif(n = 43, min = 800, max = 15800))
VAR_2 <- as.integer(runif(n = 43, min = 1000, max = 15800))
VAR_3 <- as.integer(runif(n = 43, min = 1500, max = 15800))
Cantons <- listNames(Corsica, 4)
DF <- data.frame(Cantons, VAR_1, VAR_2, VAR_3, stringsAsFactors = FALSE)

dotDensity(Corsica,
                DF,
                adm.join="Cantons",
                values = c("VAR_1", "VAR_2", "VAR_3"),
                labels = c("H1N1", "H1N2", "H2N2"),
                palette = c("#ffff00", "#ffaa00", "#FF3200"))
# }

Run the code above in your browser using DataLab