ipums_shape_join | R Documentation |
These functions are analogous to dplyr's joins, except that:
They operate on a data frame and an sf
object
They retain the variable attributes provided in IPUMS files and loaded by ipumsr data-reading functions
They handle minor incompatibilities between attributes in spatial and tabular data that emerge in some IPUMS files
ipums_shape_left_join(
data,
shape_data,
by,
suffix = c("", "SHAPE"),
verbose = TRUE
)
ipums_shape_right_join(
data,
shape_data,
by,
suffix = c("", "SHAPE"),
verbose = TRUE
)
ipums_shape_inner_join(
data,
shape_data,
by,
suffix = c("", "SHAPE"),
verbose = TRUE
)
ipums_shape_full_join(
data,
shape_data,
by,
suffix = c("", "SHAPE"),
verbose = TRUE
)
data |
A tibble or data frame. Typically, this will contain data that has been aggregated to a specific geographic level. |
shape_data |
An |
by |
Character vector of variables to join by. See |
suffix |
If there are non-joined duplicate variables in the two data sources, these suffixes will be added to the output to disambiguate them. Should be a character vector of length 2. Defaults to adding the |
verbose |
If |
An sf
object containing the joined data
data <- read_nhgis(
ipums_example("nhgis0972_csv.zip"),
verbose = FALSE
)
sf_data <- read_ipums_sf(ipums_example("nhgis0972_shape_small.zip"))
joined_data <- ipums_shape_inner_join(data, sf_data, by = "GISJOIN")
colnames(joined_data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.