qualmap (version 0.1.1)

qm_create: Create cluster object

Description

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

Usage

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. Additionally, a variable called COUNT is created. This will always be equal to 1 for each observation. It is intended to be used for summarization later in the data analysis process. Finally, 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

Run this code
# NOT RUN {
# 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")

# 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)

# }

Run the code above in your browser using DataLab