Skip to content

Commit

Permalink
Enhance help page for check_contiguity
Browse files Browse the repository at this point in the history
Add more verbal examples so it is easy to understand
  • Loading branch information
kuriwaki authored Dec 10, 2021
1 parent b702cea commit 36d1db9
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions R/contiguity.R
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
#' Check Contiguity by Group
#'
#' @param adj adjacency list
#' @param group array of group identifiers. Typically district numbers or county names.
#' Identify contiguous sets of units and numbers each set. Can be extended to repeat the procedure
#' within a subgeography.
#'
#' @return tibble with a column for each of inputted group, created group number, and the
#' identified connected component number
#' @param adj An adjacency list from `adjacency()`
#' @param group To check contiguity within larger groups such as counties, specify the group identifiers.
#' Typically input district numbers or county names.
#'
#' @return tibble with contiguity indicators. Each row is the units of `adj`. Columns include
#' - `group` Values of the inputted `group` argument. If `group` is not specified, then all values
#' will be 1.
#' - `component` A number for each contiguous set of units within a `group`. If all units within a
#' `group` are contiguous, all values are 1. If there are two sets, each discontiguous with
#' the other, the larger one will be numbered 1 and the smaller one will be numbered as 2.
#'
#' @concept fix
#'
#' @export
#' @examples
#' data(checkerboard)
#' adj <- adjacency(checkerboard)
#' check_contiguity(adj)
#'
#' check_contiguity(adj) # all contiguous
#' # If there are two discontiguous groups, there will be 2 values of `component`
check_contiguity <- function(adj, group) {
if (missing(adj)) {
cli::cli_abort('Please provide an argument to {.arg adj}.')
Expand Down

0 comments on commit 36d1db9

Please sign in to comment.