Each vector of input values is converted to a tibble organized in a "tidy" fashion.

qm_create(ref, key, value, rid, cid, category, ...)

Arguments

ref

An sf object that serves as a master list of features

key

Name of geographic id variable in the ref object to match input values to

value

A vector of input values created with qm_define

rid

Respondent identification number; a user defined integer value that uniquely identifies respondents in the project

cid

Cluster identification number; a user defined integer value that uniquely identifies clusters

category

Category type; a user defined value that describes what the cluster represents

...

An unquoted list of variables from the sf object to include in the output

Value

A tibble with the cluster values merged with elements of the reference data. This tibble is stored with a custom class of qm_cluster to facilitate data validation.

Details

A cluster object contains a row for each feature in the reference data set. The key variable values are included in a variable named identically to the key. Three pieces of metadata are also included as arguments to provide data for subsetting later: a respondent identification number (rid), a cluster identification number (cid), and a category for the cluster type (category). These arguments are converted into values for the output variables RID, CID, and CAT respectively. Input data for qm_create are validated using qm_validate as part of the cluster object creation process.

See also

qm_define, qm_validate

Examples

# load and format reference data
stl <- stLouis
stl <- dplyr::mutate(stl, TRACTCE = as.numeric(TRACTCE))

# create cluster
cluster <- qm_define(118600, 119101, 119300)

# create simple cluster object
cluster_obj1 <- qm_create(ref = stl, key = TRACTCE, value = cluster,
    rid = 1, cid = 1, category = "positive")
#> old-style crs object detected; please recreate object with a recent sf::st_crs()

# create cluster object with additional variables added from reference data
cluster_obj2 <- qm_create(ref = stl, key = TRACTCE, value = cluster,
    rid = 1, cid = 1, category = "positive", NAME, NAMELSAD)
#> old-style crs object detected; please recreate object with a recent sf::st_crs()