Learn R Programming

segregation (version 1.1.0)

mutual_total_nested: Calculates a nested decomposition of segregation for M and H

Description

Returns the between-within decomposition defined by the sequence of variables in unit.

Usage

mutual_total_nested(data, group, unit, weight = NULL, base = exp(1))

Value

Returns a data.table similar to mutual_total, but with column between and within that define the levels of nesting.

Arguments

data

A data frame.

group

A categorical variable or a vector of variables contained in data. Defines the first dimension over which segregation is computed.

unit

A vector of variables contained in data. Defines the levels at which the decomposition should be computed.

weight

Numeric. (Default NULL)

base

Base of the logarithm that is used in the calculation. Defaults to the natural logarithm.

Examples

Run this code
mutual_total_nested(schools00, "race", c("state", "district", "school"),
    weight = "n"
)
# This is a simpler way to run the following manually:
# mutual_total(schools00, "race", "state", weight = "n")
# mutual_total(schools00, "race", "district", within = "state", weight = "n")
# mutual_total(schools00, "race", "school", within = c("state", "district"), weight = "n")

Run the code above in your browser using DataLab