composition: Calculate compositional measurements (Proportion, Diversity,...

Description Usage Arguments Details Value Examples

Description

This function outputs a dataframe containg serveral compositional measures for ego-centered-network data. It reports the proportion of each group in the network, the absolute count of groups present and, if provided the corresponding ego attribute, the EI-Index is employed as a measurment for ego's tendency to homo-/heterophily.

Usage

1
2
composition(alteri, v_alt, netsize, egoID = "egoID", v_ego = NULL,
  mode = "regular")

Arguments

alteri

Data frame containing alteri data (alteri as cases), alteri are separated by a variable containg an egoID.

v_alt

A character naming the variable containg the alter-attribute.

netsize

Vector containing values of network size per ego.

egoID

Character. Name of the variable identifying egos (default: "egoID").

v_ego

Character vector containing the ego attribute. Only needed for homophily index (EI). Caution: Levels of v_alt and v_ego need to correspond (see Details).

mode

A character. "regular" for a basic output, "all" for a complete output.

Details

v_ego is expected to consist of one entry per ego. The ego attributes are usually drawn from the ego dataframe. If the ego attribute is stored alongside the alteri data, make sure to drop repeated values per alteri (see example two).

Value

Returns a dataframe with category counts, diversity and EI-Index values in an ego-centered network for a provided alter attribute.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Load example data
data("egos32")
data("alteri32")

# Example one
composition(alteri32, v_alt = "alter.sex", netsize = egos32$netsize, 
            v_ego = egos32$sex)

# Example two
# - using an ego attribute stored in the alter dataframe.
ego.sex <- alteri32[!duplicated(alteri32$egoID), ]$ego.sex
res <- composition(alteri32, v_alt = "alter.sex", netsize = egos32$netsize, 
                   v_ego = ego.sex)

# Using cbind() to show the ego attribute alongside the results might
# be helpful in many cases:
cbind(res, ego.sex)

tilltnet/egonetR documentation built on May 31, 2019, 1:46 p.m.