plotGridMap: Plots a filled grid map of US states, represented as hexagons

Description Usage Arguments Value Examples

View source: R/plotGridMap.R

Description

Plots a filled grid map of US states, represented as hexagons

Usage

1
2
3
plotGridMap(x, state_var = "state.abb", fill_var, alpha_var = NULL,
  label_var = state_var, label_color_var = NULL,
  label_color = "black", outline_color = "black")

Arguments

x

data.frame with data to plot

state_var

name of of column in x that contains state abbreviations (matching base::state.abb())

fill_var

column from x to use for color fill; can be numeric, factor, or character (treated as factor by ggplot)

alpha_var

column from x to use for fill alpha (NULL by default, for no alpha); can be numeric, factor, or character (treated as factor by ggplot)

label_var

name of column in x to use for labels; if NULL, then no labels

label_color_var

if NULL, then labels have a fixed color (specified by label_color). Otherwise, name of column in x to use for label color scale

label_color

color for label text. Has no effect if you pass a value to label_color_var

outline_color

color for state hex outlines

Value

Returns a ggplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# a data.frame of states with random categorical value
my_dat <- data.frame(state.abb, value=sample(LETTERS[1:5], 50, replace=T))

# build grid map plot
my_dat <- data.frame(state.abb = c(state.abb, 'DC'),
                     value=sample(LETTERS[1:5], 51, replace=T))

# note you can manipulate the resultant object as you would any ggplot object
my_grid_map +
 scale_fill_brewer(type='qual') +
 labs(title = 'States by Category', fill = 'Category')

arvi1000/rGridMap documentation built on Oct. 13, 2019, 7:34 a.m.