eiCompare (version 3.0.0)

merge_voter_file_to_shape: Merges a voter file to a shape file.

Description

This is achieved by determining the units (e.g., Census block, district, etc.) for which each voter's address lies within.

Usage

merge_voter_file_to_shape(
  voter_file,
  shape_file,
  crs = NULL,
  coords = c("lon", "lat"),
  voter_id = "voter_id"
)

Arguments

voter_file

A dataframe denoting the voter file. If it is not a geometry dataframe, it will be converted to one.

shape_file

The shapefile for the region, as an sf object.

crs

The PROJ4 string or int for the coordinate reference system.

coords

The columns, as a list, that refer to the longitude and latitude.

voter_id

The column for the Voter ID.

Value

The voter file with unit information attached.

Details

This function assumes that the sf package was used to read in the shape files.