shift: Shift region on a map

Description Usage Arguments Examples

View source: R/process.R

Description

Shift region on a map

Usage

1
shift(map, condition = NULL, shift_by = c(0, 0), set_to = NULL)

Arguments

map

map object as generated by 'process_shape' or 'ggplot2::map_data'

condition

logical expression describing the subset of the map to use for the scaling

shift_by

numeric vector of length 2. Relative shift in geographic latitude and longitude.

set_to

numeric vector of length 2. Set center of the region (defined by range in lat and long) to this longitude and latitude

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
data(states)
states %>%
  shift(DIVISION == "1", shift_by=c(7.5, 0)) %>%
  shift(DIVISION == "2", shift_by=c(5, 0)) %>%
  shift(DIVISION == "3", shift_by=c(2.5, 0)) %>%
  shift(DIVISION == "5", shift_by=c(5, -1.5)) %>%
  shift(DIVISION == "6", shift_by=c(2.5, -1.5)) %>%
  shift(DIVISION == "9", shift_by=c(-5, 0)) %>%
  shift(DIVISION == "8", shift_by=c(-2.5, 0)) %>%
  shift(DIVISION == "7", shift_by=c(0, -1.5)) %>%
  filter(lat > 20) %>%
  ggplot(aes(long, lat)) + geom_polygon(aes(group=group, fill=factor(DIVISION)))

states01 %>%
  shift(REGION == "4", shift_by=c(-2.5, 0)) %>%
  shift(REGION == "1", shift_by=c(1.25, 0)) %>%
  shift(REGION == "3", shift_by=c(0, -1.25)) %>%
  filter(lat > 20) %>%
  ggplot(aes(long, lat)) + geom_polygon(aes(group=group, fill=factor(REGION)))

heike/ggmapr documentation built on May 17, 2019, 3:23 p.m.