geo_neighbors: Calculate a neighborhood matrix from an sf object

Description Usage Arguments Value Examples

View source: R/geo_neighbours.R

Description

Calculates a neighborhood matrix from a list of geoids which correspond to either tract of block group ids for a given year. Alternatively calculates neighborhood matrix for a sf data frame of polygons

Usage

1
2
3
4
5
6
7
geo_neighbors(
  GEOIDs = NULL,
  year = 2010,
  geoid_sf = NULL,
  matrix = FALSE,
  queen = TRUE
)

Arguments

GEOIDs

Character vector of GEOIDs of either tracts or block groups

year

The year, or endyear, of the ACS sample or Census. 2012 through 2018 are available for ACS and 2000 and 2010 for Census. Defaults to 2010.

geoid_sf

Alternative specification where an sf object is supplied and neighborhoods are calculated directly from that object

matrix

Logical whether to return a matrix rather than data frame.

queen

Logical, use queen algorithm of adjacency rather than rook.

Value

data frame or matrix indicating adjacency with logical values

Examples

1
2
# get neighbors of all 2010 tracts from Wake county North Carolina
geo_neighbors(get_decennial_race("NC", "Wake")$GEOID)

nmmarquez/censeg documentation built on Sept. 12, 2020, 4:13 a.m.