qm_create {qualmap} | R Documentation |
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 |
key |
Name of geographic id variable in the |
value |
A vector of input values created with |
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 |
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.
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.
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")
# 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)