spReapportion: Reapportion data from one geography to another

Description Usage Arguments Note Author(s)

View source: R/spReapportion.R

Description

This function allows to reapportion data from one geography to another, for example in the context of working with different administrative units.

Usage

1
2
3
4
spReapportion(old_geom, new_geom, data, old_ID, new_ID, data_ID,
  variables = names(data)[-which(names(data) %in% data_ID)],
  mode = "count", weights = NULL, weight_matrix = NULL,
  weight_matrix_var = NULL)

Arguments

old_geom

a 'SpatialPolygonsDataFrame' representing the initial geometry.

new_geom

a 'SpatialPolygonsDataFrame' representing the geometry you want to reapportion data to.

data

a 'data.frame' containing the data to reapportion, and an ID allowing to match it to the 'old_geom'.

old_ID

a string, the name of the ID variable in the 'old_geom'.

new_ID

a string, the name of the ID variable in the 'new_geom'.

data_ID

a string, the name of the ID variable in the 'data'.

variables

a character vector, representing the names of the variables in the 'data' set to reapportion. By default, all data variables except for the ID.

mode

either '"count"' or '"proportion"'. '"count"' is for absolute values, '"proportion"' is for, well, proportions (expressed between 0 and 1). If '"proportion"', you need to provide a weights variable.

weights

In case the variables are proportions, the name of the variable containing weights (i.e. the total number of observations per unit in the 'old_geom').

weight_matrix

a SpatialPointsDataFrame indicating where are the observations (inhabitants, voters, etc.) (optional).

weight_matrix_var

the name of the variable in weight_matrix containing the weights.

Note

Inspiration from http://stackoverflow.com/a/17703903 and http://rstudio-pubs-static.s3.amazonaws.com/6577_3b66f8d8f4984fb2807e91224defa854.html. All mistakes are mine, obviously.

Author(s)

Joel Gombin


joelgombin/spReapportion documentation built on May 19, 2019, 3 p.m.