This function imports ego-centered network data, stored in two files, where one file contains the ego attributes and the edge information and the other file contains the alters data. This form of data storage for ego-centered network data is proposed by Muller, Wellman and Marin (1999).
twofiles_to_egor(
egos,
alters,
ID.vars = list(ego = "egoID", alter = "alterID", source = "Source", target = "Target"),
max.alters,
aa.first.var,
selection = NULL,
...
)
Data frame
containing ego data (egos as cases)
Data frame
containing alters data (alters in rows),
alters are connected to their ego by an egoID
.
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.
Maximum number of alters that are included in edge data.
Index or name of the first column in egos
containing alter-alter data.
Character
naming numeric
variable indicating
alters selection with zeros and ones.
additional arguments to egor()
.
An egor object is returned. It is a list
of three data frames:
(1) ego: dataframe
of all
egos and their attributes;
(2) alter: dataframe
of all alters;
(3) aatie: dataframe
of alter alter ties/ edges
path_to_alters_8.csv <- system.file("extdata", "alters_8.csv", package = "egor")
path_to_one_file_8 <- system.file("extdata", "one_file_8.csv", package = "egor")
# read data from disk
egos_8 <- read.csv2(path_to_one_file_8)
alters_8 <- read.csv2(path_to_alters_8.csv)
# convert to egor object
twofiles_to_egor(
egos = egos_8,
alters = alters_8,
max.alters = 8,
aa.first.var = "X1.to.2")
#> Sorting data by egoID and alterID.
#> Transforming wide edge data to edgelist.
#> # EGO data (active): 16 × 49
#> .egoID sex age netsize egoID.1 alter.…¹ alter…² alter…³ alter…⁴ alter…⁵
#> * <int> <chr> <chr> <int> <int> <chr> <chr> <chr> <chr> <chr>
#> 1 1 w 66 - 100 8 1 w 66 - 1… w 0 - 17 m
#> 2 2 m 18 - 25 8 2 w 36 - 45 m 46 - 55 w
#> 3 3 w 26 - 35 8 3 w 56 - 65 m 18 - 25 w
#> 4 4 w 0 - 17 8 4 w 46 - 55 m 36 - 45 w
#> 5 5 m 36 - 45 8 5 w 18 - 25 w 0 - 17 m
#> # … with 11 more rows, 39 more variables: alter.age.3 <chr>, alter.sex.4 <chr>,
#> # alter.age.4 <chr>, alter.sex.5 <chr>, alter.age.5 <chr>, alter.sex.6 <chr>,
#> # alter.age.6 <chr>, alter.sex.7 <chr>, alter.age.7 <chr>, alter.sex.8 <chr>,
#> # alter.age.8 <chr>, X1.to.2 <int>, X1.to.3 <int>, X1.to.4 <int>,
#> # X1.to.5 <int>, X1.to.6 <int>, X1.to.7 <int>, X1.to.8 <int>, X2.to.3 <int>,
#> # X2.to.4 <int>, X2.to.5 <int>, X2.to.6 <int>, X2.to.7 <int>, X2.to.8 <int>,
#> # X3.to.4 <int>, X3.to.5 <int>, X3.to.6 <int>, X3.to.7 <int>, …
#> # ALTER data: 128 × 4
#> .altID .egoID alter.sex alter.age
#> * <dbl> <int> <chr> <chr>
#> 1 1 1 w 18 - 25
#> 2 2 1 w 46 - 55
#> 3 3 1 m 0 - 17
#> # … with 125 more rows
#> # AATIE data: 448 × 4
#> .egoID .srcID .tgtID weight
#> * <int> <dbl> <dbl> <int>
#> 1 1 1 2 2
#> 2 1 1 3 3
#> 3 1 1 4 1
#> # … with 445 more rows