Description Usage Arguments Details Value See Also Examples
View source: R/zero_matrix_nest.R
Create a structural zero matrix representing a situation where one set of categories is nested within another - eg counties within states, or detailed occupations within broad occupational categories.
1 | zero_matrix_nest(nest)
|
nest |
A data.frame providing a mapping between the higher-level and lower-level categories. |
Nesting can be contrasted with crossing, where each set of categories are independent of the others, eg age vs sex.
nest
is a data.frame providing a mapping between
the higher-level categories and lower-level categories.
nest
has two columns: one with the higher-level
categories, and one with the lower-level categories.
Each row gives the higher-level category associated with a
lower-level category. The order of the columns and rows
does not matter.
Each lower-level category can belong to only one higher-level category.
zero_matrix_nest
returns a logical matrix
indicating whether each lower-level category
nests within the corresponding higher-level category.
A matrix of TRUE
s and FALSE
s,
with dimnames constructed from nest
.
Function add_dim_nest
adds a
dimension representing the higher-level categories to
an array containing the lower-level categories.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | nest <- data.frame(region = c("Asia", "Africa", "Africa"),
country = c("India", "Nigeria", "Zimbabwe"))
zero_matrix_nest(nest)
nest <- data.frame(level2 = c("Bacterial infections",
"Viral infections",
"Infections caused by fungi",
"Lip, oral cavity, pharynx",
"Digestive organs"),
level1 = c("Infectious and parasitic diseases",
"Infectious and parasitic diseases",
"Infectious and parasitic diseases",
"Neoplasms",
"Neoplasms"))
zero_matrix_nest(nest)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.