The function egor() is used to create an egor object from ego-centered network data.

egor(
  alters,
  egos = NULL,
  aaties = NULL,
  ID.vars = list(ego = "egoID", alter = "alterID", source = "Source", target = "Target"),
  ego_design = list(~1),
  alter_design = list(max = Inf)
)

as.egor(x, ...)

Arguments

alters

either a data.frame containing the alters (whose nominator is identified by the column specified by egoID or a list of data frames with the same columns, one for each ego, with empty data frames or NULLs corresponding to egos with no nominees.

egos

data.frame containing the egos.

aaties

data.frame containing the alter-alter relations in the style of an edge list, or a list of data frames similar to alters.df.

ID.vars

A named list containing column names of the relevant input columns:

ego

unique identifier associated with each ego, defaulting to "egoID"; has no effect if alters.df and aaties.df are both lists of data frames.

alter

unique-within-ego identifier associated with each alter, defaulting to "alterID"; optional aaties.df are not provided.

source

if aaties.df is provided, the column given the alter identifier of the origin of a relation.

target

if aaties.df is provided, the column given the alter identifier of the destination of a relation.

ego_design

A list of arguments to survey::svydesign() specifying the sampling design for the egos. If formulas, they can refer to columns of egos.df.

alter_design

A list of arguments specifying nomination information. Currently, the following elements are supported:

x

an object to be coerced to egor.

...

arguments to be passed to methods

Value

Returns an egor object. An egor object is a tibble whose top-level columns store the ego attributes, and which has two special nested columns: .alts, containing, for each row (ego) a table of that ego's alter attributes and .aaties, a table containing that ego's alter--alter ties, if observed.

If alter-alter ties are observed, .alts also has a column .altID giving a unique (within each ego) ID of the alter, by which the alter can be identified in the .aaties table for that ego. .aaties, in turn, has columns .srcID and .tgtID that contain the source and the target of the alter-alter relation.

In addition, egor has two attributes: ego_design, containing an object returned by survey::svydesign() specifying the sampling design by which the egos were selected and alter_design, a list containing specification of how the alters were nominated. See the argument above for currently implemented settings.

Details

If parameters alters.df, egos.df, and aaties.df are data frames, they need to share a common ego ID variable, with corresponding values. If alters.df and aaties.df are lists of data frames, egoID is ignored and they are matched positionally with the rows of egos.df. Of the three parameters only alters.df is necessary to create an egor object, and egos.df and aaties.df are optional.

Note

Column names .alts, .aaties, and .egoRow are reserved for internal use of egor and should not be used to store persistent data. Other .-led column names may be reserved in the future.

Examples

data("egos32") data("alters32") data("aaties32") egor(alters32, egos32, aaties32, ID.vars = list(ego = ".EGOID", alter = ".ALTID", source = ".SRCID", target = ".TGTID"))
#> # EGO data (active) #> # A tibble: 32 x 6 #> .egoID sex age age.years country income #> <fct> <fct> <fct> <int> <fct> <dbl> #> 1 1 w 36 - 45 45 USA 36135 #> 2 2 m 36 - 45 37 Germany 35040 #> 3 3 m 26 - 35 28 Australia 63875 #> # … with 29 more rows #> # ALTER data #> # A tibble: 478 x 7 #> .altID .egoID sex age age.years country income #> <int> <fct> <fct> <fct> <int> <fct> <dbl> #> 1 1 1 w 66 - 100 75 Australia 42340 #> 2 2 1 m 18 - 25 17 Germany 730 #> 3 3 1 w 66 - 100 91 Australia 23360 #> # … with 475 more rows #> # AATIE data #> # A tibble: 1,858 x 4 #> .egoID .srcID .tgtID weight #> <fct> <int> <int> <dbl> #> 1 32 13 18 0.333 #> 2 18 11 22 0.667 #> 3 28 5 19 0.667 #> # … with 1,855 more rows