segplot: A visual representation of segregation

View source: R/plots.R

segplotR Documentation

A visual representation of segregation

Description

Produces a segregation plot.

Usage

segplot(
  data,
  group,
  unit,
  weight,
  order = "segregation",
  reference_distribution = NULL,
  bar_space = 0,
  title = NULL,
  axis_labels = "left"
)

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 categorical variable or a vector of variables contained in data. Defines the second dimension over which segregation is computed.

weight

Numeric. (Default NULL)

order

A character, either "segregation", "entropy", "majority", or "majority_fixed". Affects the ordering of the units. The horizontal ordering of the groups can be changed by using a factor variable for group. The difference between "majority" and "majority_fixed" is that the former will reorder the groups in such a way that the majority group actually comes first. If you want to control the ordering yourself, use "majority_fixed" and specify the group variable as a factor variable.

reference_distribution

Specifies the reference distribution, given as a two-column data frame, to be plotted on the right. If order is segregation, then this reference distribution is also used to compute the local segregation scores.

bar_space

Specifies space between single units.

title

Adds a plot title and appends the value of the H index.

axis_labels

One of "left", "right", or "both". Determines where the y axis labels are placed.

Value

Returns a ggplot2 object.


segregation documentation built on Aug. 25, 2023, 1:07 a.m.