The function egor() is used to create an egor object from
ego-centered network data. as.egor() converts a list of igraph/network objects or
a nested_egor objects to an egor object.
Usage
as.egor(x, ...)
# S3 method for class 'nested_egor'
as.egor(
x,
ID.vars = list(ego = ".egoID", alter = ".alterID", source = ".Source", target =
".Target"),
...
)
# S3 method for class 'list'
as.egor(x, ego_name = NULL, ...)
egor(
alters,
egos = NULL,
aaties = NULL,
ID.vars = list(ego = "egoID", alter = "alterID", source = "Source", target = "Target"),
ego_design = NULL,
alter_design = list(max = Inf)
)Arguments
- x
listofigraph/networkobjects representing ego networks.- ...
arguments to be passed to methods
- ID.vars
A named list containing column names of the relevant input columns:
egounique identifier associated with each ego, defaulting to
"egoID"; has no effect ifalters.dfandaaties.dfare both lists of data frames.alterunique-within-ego identifier associated with each alter, defaulting to
"alterID"; optionalaaties.dfare not provided.sourceif
aaties.dfis provided, the column given the alter identifier of the origin of a relation.targetif
aaties.dfis provided, the column given the alter identifier of the destination of a relation.
- ego_name
characterornumericof length one or same length as there are networks. If theigraph/networkobjects don't include egos as a node, set toNULL(default).- alters
either a
data.framecontaining the alters (whose nominator is identified by the column specified byegoIDor a list of data frames with the same columns, one for each ego, with empty data frames orNULLs corresponding to egos with no nominees.- egos
data.framecontaining the egos.- aaties
data.framecontaining the alter-alter relations in the style of an edge list, or a list of data frames similar toalters.df.- ego_design
A
listof arguments tosrvyr::as_survey_design()specifying the sampling design for the egos in terms of the ego variables. Variable names can be referenced as strings, as one-sided formulas, or usingdplyr::select()syntax. It is recommended to usealist()rather thanlist()to construct this argument, particularly when using theselect()syntax. PassNULLto set no design.- alter_design
A
listof arguments specifying nomination information. Currently, the following elements are supported:
Value
Returns an egor object, which is a named list with three
tibble data.frames: ego, alter and aatie (alter-alter ties).
Each data set has an .egoID column, that groups the data belonging to one
ego. Additionally the alter data has an .alterID column, that links to
the columns .srcID and .tgtID in the alter-alter tie data.
In addition, egor has two attributes: ego_design, containing an
object returned by srvyr::as_survey_design() 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 by position
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.
See also
tibble::as_tibble() for extracting ego, alter, and alter–alter tables, as tibble::tibbles or as srvyr's srvyr::tbl_svy surveys.
Examples
data("egos32")
data("alters32")
data("aaties32")
e <- egor(alters32,
egos32,
aaties32,
ID.vars = list(ego = ".EGOID",
alter = ".ALTID",
source = ".SRCID",
target = ".TGTID"),
ego_design = alist(strata = sex))
e
#> # EGO data with survey design (active): 32 × 6
#> .egoID sex age age.years country income
#> * <dbl> <chr> <fct> <int> <chr> <dbl>
#> 1 1 m 56 - 65 63 Australia 29930
#> 2 2 m 26 - 35 33 Germany 17885
#> 3 3 m 66 - 100 74 Germany 20805
#> 4 4 w 18 - 25 21 Poland 29565
#> 5 5 m 0 - 17 9 Germany 15330
#> # ℹ 27 more rows
#> # ALTER data: 384 × 7
#> .altID .egoID sex age age.years country income
#> * <int> <dbl> <chr> <fct> <int> <chr> <dbl>
#> 1 1 1 m 46 - 55 48 USA 45625
#> 2 2 1 m 0 - 17 5 Germany 52925
#> 3 3 1 w 26 - 35 35 Australia 60225
#> # ℹ 381 more rows
#> # AATIE data: 1,056 × 4
#> .egoID .srcID .tgtID weight
#> * <int> <int> <int> <dbl>
#> 1 20 1 2 0.667
#> 2 25 6 10 0.667
#> 3 9 6 8 0.667
#> # ℹ 1,053 more rows
ego_design(e)
#> Stratified Independent Sampling design (with replacement)
#> Called via srvyr
#> Sampling variables:
#> - ids: `1`
#> - strata: sex
#> Data variables:
#> - .egoID (dbl), sex (chr), age (fct), age.years (int), country (chr), income
#> (dbl)