Description Usage Arguments Note Author(s)
View source: R/spReapportion.R
This function allows to reapportion data from one geography to another, for example in the context of working with different administrative units.
1 2 3 4 |
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 |
Inspiration from http://stackoverflow.com/a/17703903 and http://rstudio-pubs-static.s3.amazonaws.com/6577_3b66f8d8f4984fb2807e91224defa854.html. All mistakes are mine, obviously.
Joel Gombin
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.